@springtree/eva-sdk-redux-store-builder
v6.0.59
Published
Provide the means to create an EVA focused Redux store
Downloads
1,072
Keywords
Readme
@springtree/eva-sdk-redux-store-builder
This library provides the functionality to create a Redux store for the EVA backend. It will add some basic feature like endpoint selection and current user support. Please the SDK documentation for how to add services and your own logic to your store.
Usage
import { ReducersMapObject } from 'redux';
import { Logic } from 'redux-logic';
import { bootstrapEndpoint } from '@springtree/eva-sdk-core-service';
import {
StoreBuilder,
IEvaReduxStoreDefaultShape,
createCurrentUserTokenAction,
} from '@springtree/eva-sdk-redux-store-builder';
const url = 'https://api.eva-dev.on-eva.io';
// Declare your redux store extensions
//
export interface IMyReduxStore extends IEvaReduxStoreDefaultShape {
// TODO: Add your state properties
}
const reducers: ReducersMapObject<Partial<IMyReduxStore>> = {
// TODO: Add your state reducers
};
const logics: Logic[] = [
// TODO: Add your state effects logic
];
// Create the default EVA redux store which contains current user support
// out-of-the-box
//
const builder = new StoreBuilder<IMyReduxStore>();
const store = builder.createStore({
reducers,
logics,
initialState: { endpointUrl: url },
});
// (Optional) Create an RxJs observable for the store state
//
const store$ = createStoreObservable(store);