Skip to content

Commit 92053f1

Browse files
feat(state): Expose the internal state API via $$state()
Closes #13
1 parent 88c624d commit 92053f1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/state/interface.ts

+7
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ export interface StateDeclaration {
127127
* ```
128128
*/
129129
parent?: (string|StateDeclaration);
130+
131+
/**
132+
* Gets the private API portion of the state
133+
*
134+
* @hidden
135+
*/
136+
$$state?: () => State;
130137

131138
/**
132139
* A property of [[StateDeclaration]]:

src/state/stateBuilder.ts

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export class StateBuilder {
5353
const root = () => matcher.find("");
5454

5555
this.builders = {
56+
self: [function (state: State) {
57+
state.self.$$state = () => state;
58+
return state.self;
59+
}],
60+
5661
parent: [function (state: State) {
5762
if (isRoot(state)) return null;
5863
return matcher.find(self.parentName(state)) || root();

0 commit comments

Comments
 (0)