Skip to content

Commit

Permalink
Mutation Sandbox API
Browse files Browse the repository at this point in the history
  • Loading branch information
axmmisaka committed Sep 6, 2023
1 parent 7317bfb commit 5b53bf7
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 @@ -475,6 +475,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 @@ -1586,10 +1600,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 @@ -1833,6 +1844,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 5b53bf7

Please sign in to comment.