SinkContainer use to keep store and all the sinks within the same scope.
Since SinkFactory is an instance of SinkContainer the API is the same, all the code example will be using SinkFactory for easier understanding the usage.
createStore(SinkConfiguration) => Store
Create sink store, it can take reducers, middlewares and devToolOptions with configuration
interfaceSinkConfiguration {// regular reducers reducers: { [key:string]: (state, action) =>state },// predefined state preloadedState: { ...state },// additional middlewares middlewares:Array<ReduxMiddleware>,// use effect trace, default false useEffectTrace?:boolean;// use effect, default false useTrigger?:boolean;// required compose function from redux-dev-tool devToolOptions: {// devTool compose functiondevToolCompose:Function,// should devTool disabled disabled?:boolean,// other devTool properties [key:string]:any }}
import { SinkFactory } from'redux-sink';// its also possible to add reducers and middlewares through this apiconststore=SinkFactory.createStore({ reducers, preloadedState, middlewares, useEffectTrace:true, useTrigger:true, devToolOptions: { devToolCompose: composeWithDevTools } });
getSink(SinkClass) => SinkInstance
Get sink from the current container using sink class
import { SinkFactory } from'redux-sink';Promise.all(SinkFactory.getEffectTasks()).then(() => {// do something when all effects completed});
getStore() => Store
Get underlining redux store from the container
import { SinkFactory } from'redux-sink';// use store to dispatch a location event, just like regular reduxSinkFactory.getStore().dispatch({ type:'navigation/loaction', payload: { pathname:'/' }});// get global state of the storeconststate=SinkFactory.getStore().getState();