mirror of
https://github.com/status-im/subspace-docs.git
synced 2025-02-12 20:46:33 +00:00
18 lines
571 B
Markdown
18 lines
571 B
Markdown
# redux
|
|
Observables can be used with `redux`. The subscription can dispatch actions using if it has access to the redux store:
|
|
|
|
```js
|
|
// This example assumes it has access redux store, and the reducer
|
|
// and middleware have been configured correctly, and phoenix has
|
|
// been initialized.
|
|
|
|
const store = ... //
|
|
|
|
const myAction = eventData => ({type: 'MY_ACTION', eventData});
|
|
|
|
const myObservable = eventSyncer.trackEvent(SimpleStorageContract, "MyEvent", { filter: {}, fromBlock: 1});
|
|
|
|
myObservable.subscribe(eventData => {
|
|
store.dispatch(myAction(eventData));
|
|
});
|
|
``` |