Skip to content

Commit

Permalink
Mutation Sandbox API
Browse files Browse the repository at this point in the history
  • Loading branch information
axmmisaka authored and Kagamihara Nadeshiko committed Oct 18, 2023
1 parent 9d36711 commit bd2290b
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/core/reactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,20 @@ export abstract class Reactor extends Component {
public delete(reactor: Reactor): void {
reactor._delete();
}

public addChild<R extends Reactor, G extends unknown[]>(
constructor: new (container: Reactor, ...args: G) => R,
...args: G
): R {
return this.reactor._addChild(constructor, ...args);
}

public addSibling<R extends Reactor, G extends unknown[]>(
constructor: new (container: Reactor, ...args: G) => R,
...args: G
): R {
return this.reactor._addSibling(constructor, ...args);
}
};

/**
Expand Down Expand Up @@ -1639,10 +1653,7 @@ export abstract class Reactor extends Component {
`Reactor ${this} is self-contained. Adding sibling creates logical issue.`
);
}
const newReactor = this._getContainer()._addChild(
constructor,
...args
);
const newReactor = this._getContainer()._addChild(constructor, ...args);
this._creatorKeyChain.set(newReactor, newReactor._key);
return newReactor;
}
Expand Down Expand Up @@ -1889,6 +1900,16 @@ export interface MutationSandbox extends ReactionSandbox {

getReactor: () => Reactor; // Container

addChild: <R extends Reactor, G extends unknown[]>(
constructor: new (container: Reactor, ...args: G) => R,
...args: G
) => R;

addSibling: <R extends Reactor, G extends unknown[]>(
constructor: new (container: Reactor, ...args: G) => R,
...args: G
) => R;

// FIXME:
// forkJoin(constructor: new () => Reactor, ): void;
}
Expand Down

0 comments on commit bd2290b

Please sign in to comment.