Skip to content

Commit 5b53bf7

Browse files
committed
Mutation Sandbox API
1 parent 7317bfb commit 5b53bf7

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/core/reactor.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,20 @@ export abstract class Reactor extends Component {
475475
public delete(reactor: Reactor): void {
476476
reactor._delete();
477477
}
478+
479+
public addChild<R extends Reactor, G extends unknown[]>(
480+
constructor: new (container: Reactor, ...args: G) => R,
481+
...args: G
482+
): R {
483+
return this.reactor._addChild(constructor, ...args);
484+
}
485+
486+
public addSibling<R extends Reactor, G extends unknown[]>(
487+
constructor: new (container: Reactor, ...args: G) => R,
488+
...args: G
489+
): R {
490+
return this.reactor._addSibling(constructor, ...args);
491+
}
478492
};
479493

480494
/**
@@ -1586,10 +1600,7 @@ export abstract class Reactor extends Component {
15861600
`Reactor ${this} is self-contained. Adding sibling creates logical issue.`
15871601
);
15881602
}
1589-
const newReactor = this._getContainer()._addChild(
1590-
constructor,
1591-
...args
1592-
);
1603+
const newReactor = this._getContainer()._addChild(constructor, ...args);
15931604
this._creatorKeyChain.set(newReactor, newReactor._key);
15941605
return newReactor;
15951606
}
@@ -1833,6 +1844,16 @@ export interface MutationSandbox extends ReactionSandbox {
18331844

18341845
getReactor: () => Reactor; // Container
18351846

1847+
addChild: <R extends Reactor, G extends unknown[]>(
1848+
constructor: new (container: Reactor, ...args: G) => R,
1849+
...args: G
1850+
) => R;
1851+
1852+
addSibling: <R extends Reactor, G extends unknown[]>(
1853+
constructor: new (container: Reactor, ...args: G) => R,
1854+
...args: G
1855+
) => R;
1856+
18361857
// FIXME:
18371858
// forkJoin(constructor: new () => Reactor, ): void;
18381859
}

0 commit comments

Comments
 (0)