mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-23 00:41:57 +00:00
Made several options functions optional
This commit is contained in:
parent
aae6455ea6
commit
94a7f41fd1
7 changed files with 13 additions and 14 deletions
|
@ -68,11 +68,11 @@ export type GenericAchievement = Replace<
|
|||
>;
|
||||
|
||||
export function createAchievement<T extends AchievementOptions>(
|
||||
optionsFunc: OptionsFunc<T, Achievement<T>, BaseAchievement>
|
||||
optionsFunc?: OptionsFunc<T, Achievement<T>, BaseAchievement>
|
||||
): Achievement<T> {
|
||||
const earned = persistent<boolean>(false);
|
||||
return createLazyProxy(() => {
|
||||
const achievement = optionsFunc();
|
||||
const achievement = optionsFunc?.() ?? ({} as ReturnType<NonNullable<typeof optionsFunc>>);
|
||||
achievement.id = getUniqueID("achievement-");
|
||||
achievement.type = AchievementType;
|
||||
achievement[Component] = AchievementComponent;
|
||||
|
|
|
@ -70,10 +70,10 @@ export type GenericClickable = Replace<
|
|||
>;
|
||||
|
||||
export function createClickable<T extends ClickableOptions>(
|
||||
optionsFunc: OptionsFunc<T, Clickable<T>, BaseClickable>
|
||||
optionsFunc?: OptionsFunc<T, Clickable<T>, BaseClickable>
|
||||
): Clickable<T> {
|
||||
return createLazyProxy(() => {
|
||||
const clickable = optionsFunc();
|
||||
const clickable = optionsFunc?.() ?? ({} as ReturnType<NonNullable<typeof optionsFunc>>);
|
||||
clickable.id = getUniqueID("clickable-");
|
||||
clickable.type = ClickableType;
|
||||
clickable[Component] = ClickableComponent;
|
||||
|
|
|
@ -20,7 +20,7 @@ export interface Link extends SVGAttributes {
|
|||
}
|
||||
|
||||
export interface LinksOptions {
|
||||
links?: Computable<Link[]>;
|
||||
links: Computable<Link[]>;
|
||||
}
|
||||
|
||||
export interface BaseLinks {
|
||||
|
|
|
@ -84,11 +84,11 @@ export type GenericMilestone = Replace<
|
|||
>;
|
||||
|
||||
export function createMilestone<T extends MilestoneOptions>(
|
||||
optionsFunc: OptionsFunc<T, Milestone<T>, BaseMilestone>
|
||||
optionsFunc?: OptionsFunc<T, Milestone<T>, BaseMilestone>
|
||||
): Milestone<T> {
|
||||
const earned = persistent<boolean>(false);
|
||||
return createLazyProxy(persistent => {
|
||||
const milestone = Object.assign(persistent, optionsFunc());
|
||||
return createLazyProxy(() => {
|
||||
const milestone = optionsFunc?.() ?? ({} as ReturnType<NonNullable<typeof optionsFunc>>);
|
||||
milestone.id = getUniqueID("milestone-");
|
||||
milestone.type = MilestoneType;
|
||||
milestone[Component] = MilestoneComponent;
|
||||
|
|
|
@ -42,10 +42,10 @@ export type Particles<T extends ParticlesOptions> = Replace<
|
|||
export type GenericParticles = Particles<ParticlesOptions>;
|
||||
|
||||
export function createParticles<T extends ParticlesOptions>(
|
||||
optionsFunc: OptionsFunc<T, Particles<T>, BaseParticles>
|
||||
optionsFunc?: OptionsFunc<T, Particles<T>, BaseParticles>
|
||||
): Particles<T> {
|
||||
return createLazyProxy(() => {
|
||||
const particles = optionsFunc();
|
||||
const particles = optionsFunc?.() ?? ({} as ReturnType<NonNullable<typeof optionsFunc>>);
|
||||
particles.id = getUniqueID("particles-");
|
||||
particles.type = ParticlesType;
|
||||
particles[Component] = ParticlesComponent;
|
||||
|
|
|
@ -101,8 +101,7 @@ export function createTabFamily<T extends TabFamilyOptions>(
|
|||
|
||||
const selected = persistent(Object.keys(tabs)[0]);
|
||||
return createLazyProxy(() => {
|
||||
const tabFamily =
|
||||
optionsFunc?.() || ({} as ReturnType<OptionsFunc<T, TabFamily<T>, BaseTabFamily>>);
|
||||
const tabFamily = optionsFunc?.() ?? ({} as ReturnType<NonNullable<typeof optionsFunc>>);
|
||||
|
||||
tabFamily.id = getUniqueID("tabFamily-");
|
||||
tabFamily.type = TabFamilyType;
|
||||
|
|
|
@ -73,10 +73,10 @@ export type GenericTreeNode = Replace<
|
|||
>;
|
||||
|
||||
export function createTreeNode<T extends TreeNodeOptions>(
|
||||
optionsFunc: OptionsFunc<T, TreeNode<T>, BaseTreeNode>
|
||||
optionsFunc?: OptionsFunc<T, TreeNode<T>, BaseTreeNode>
|
||||
): TreeNode<T> {
|
||||
return createLazyProxy(() => {
|
||||
const treeNode = optionsFunc();
|
||||
const treeNode = optionsFunc?.() ?? ({} as ReturnType<NonNullable<typeof optionsFunc>>);
|
||||
treeNode.id = getUniqueID("treeNode-");
|
||||
treeNode.type = TreeNodeType;
|
||||
treeNode[Component] = TreeNodeComponent;
|
||||
|
|
Loading…
Reference in a new issue