Skip to content

Commit bd2290b

Browse files
axmmisakaKagamihara Nadeshiko
authored andcommitted
Mutation Sandbox API
1 parent 9d36711 commit bd2290b

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
@@ -503,6 +503,20 @@ export abstract class Reactor extends Component {
503503
public delete(reactor: Reactor): void {
504504
reactor._delete();
505505
}
506+
507+
public addChild<R extends Reactor, G extends unknown[]>(
508+
constructor: new (container: Reactor, ...args: G) => R,
509+
...args: G
510+
): R {
511+
return this.reactor._addChild(constructor, ...args);
512+
}
513+
514+
public addSibling<R extends Reactor, G extends unknown[]>(
515+
constructor: new (container: Reactor, ...args: G) => R,
516+
...args: G
517+
): R {
518+
return this.reactor._addSibling(constructor, ...args);
519+
}
506520
};
507521

508522
/**
@@ -1639,10 +1653,7 @@ export abstract class Reactor extends Component {
16391653
`Reactor ${this} is self-contained. Adding sibling creates logical issue.`
16401654
);
16411655
}
1642-
const newReactor = this._getContainer()._addChild(
1643-
constructor,
1644-
...args
1645-
);
1656+
const newReactor = this._getContainer()._addChild(constructor, ...args);
16461657
this._creatorKeyChain.set(newReactor, newReactor._key);
16471658
return newReactor;
16481659
}
@@ -1889,6 +1900,16 @@ export interface MutationSandbox extends ReactionSandbox {
18891900

18901901
getReactor: () => Reactor; // Container
18911902

1903+
addChild: <R extends Reactor, G extends unknown[]>(
1904+
constructor: new (container: Reactor, ...args: G) => R,
1905+
...args: G
1906+
) => R;
1907+
1908+
addSibling: <R extends Reactor, G extends unknown[]>(
1909+
constructor: new (container: Reactor, ...args: G) => R,
1910+
...args: G
1911+
) => R;
1912+
18921913
// FIXME:
18931914
// forkJoin(constructor: new () => Reactor, ): void;
18941915
}

0 commit comments

Comments
 (0)