You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allows for a more declarative use of the ['fractal store' feature](https://github.com/angular-redux/store/blob/master/articles/fractal-store.md) introduced in v6.3.0. Sticking a `@WithSubStore` decorator on a component or service will modify the behaviour of any `@select, @select$, or @dispatch` invocations in instances of that class:
```typescript
@WithSubStore({
basePathMethodName: 'getBasePath',
localReducer: localReducerFunction,
})
@component({ /* ... */ })
class MyFractalComponent {
@input() componentId;
// Will only be called with the first non-nil value of this.componentId. Subsequent changes to the
// input will be ignored.
getBasePath() {
return [ 'some', 'redux', 'path', this.componentId ];
}
// Gets an observable to 'some.redux.path.${this.componentId}.foo'
// Under the hood:
// ngRedux.configureSubStore(
// ['some', 'redux' 'path', this.componentId],
// localReducerFunction)).select('foo')
@select() foo$: Observable<String>;
// Calls substore.dispatch() instead of NgRedux.instance.dispatch().
@dispatch() myAction = () => ({ type: 'MINE' });
}
```
Copy file name to clipboardExpand all lines: articles/fractal-store.md
+60-3Lines changed: 60 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,63 @@ existing subStore.
99
99
100
100
## What about @select, @select$, @dispatch?
101
101
102
-
We don't have decorator support for the fractal store yet. These decorators
103
-
act on the global store only right now. We're thinking about a clean way
104
-
of doing fractal decorators for a future release.
102
+
As of 6.5.0, the decorator interface has been expanded to support fractal
103
+
stores as well.
104
+
105
+
Tag your component or service with the `@WithSubStore` decorator, and a substore will be
106
+
configured behind the scenes; instance of that class's `@select`, `@select$`, and `@dispatch` decorators will now operate on that substore instead of the root store. Reworking the
107
+
example above with the decorator interface looks like this:
<li>Defined in <ahref="https://github.com/SethDavenport/ng2-redux/blob/0584dc5/src/components/dev-tools.ts#L26">src/components/dev-tools.ts:26</a></li>
1025
+
<li>Defined in <ahref="https://github.com/SethDavenport/ng2-redux/blob/0dbbb4f/src/components/dev-tools.ts#L26">src/components/dev-tools.ts:26</a></li>
1012
1026
</ul>
1013
1027
</aside>
1014
1028
<divclass="tsd-comment tsd-typography">
@@ -1038,7 +1052,7 @@ <h3>is<wbr>Enabled</h3>
1038
1052
<liclass="tsd-description">
1039
1053
<asideclass="tsd-sources">
1040
1054
<ul>
1041
-
<li>Defined in <ahref="https://github.com/SethDavenport/ng2-redux/blob/0584dc5/src/components/dev-tools.ts#L51">src/components/dev-tools.ts:51</a></li>
1055
+
<li>Defined in <ahref="https://github.com/SethDavenport/ng2-redux/blob/0dbbb4f/src/components/dev-tools.ts#L51">src/components/dev-tools.ts:51</a></li>
<p>Inherited from <ahref="devtoolsextension.html">DevToolsExtension</a>.<ahref="devtoolsextension.html#enhancer">enhancer</a></p>
1018
+
<ul>
1019
+
<li>Defined in <ahref="https://github.com/SethDavenport/ng2-redux/blob/0dbbb4f/src/components/dev-tools.ts#L26">src/components/dev-tools.ts:26</a></li>
1040
1020
</ul>
1041
-
</li>
1042
-
</ul>
1043
-
</div>
1021
+
</aside>
1022
+
<divclass="tsd-comment tsd-typography">
1023
+
<divclass="lead">
1024
+
<p>A wrapper for the Chrome Extension Redux DevTools.
1025
+
Makes sure state changes triggered by the extension
<p>Inherited from <ahref="devtoolsextension.html">DevToolsExtension</a>.<ahref="devtoolsextension.html#isenabled">isEnabled</a></p>
1049
+
<ul>
1050
+
<li>Defined in <ahref="https://github.com/SethDavenport/ng2-redux/blob/0dbbb4f/src/components/dev-tools.ts#L51">src/components/dev-tools.ts:51</a></li>
0 commit comments