Setup
Installing Packages
In order to use Objective Redux in your project, you'll need to install it along with Redux. These should be saved in the project's dependencies, since they need to be included in the final application.
npm install --save redux objective-redux
If you want to use Redux-Saga (required is you want to use StatelessControllers), install it as a project dependency as well.
npm install --save redux-saga
Adding a Provider (React)
If you're using React, you'll need to setup a provider for the ObjectiveStore class. This will allow components to access the ObjectiveStore instance, either by connecting the component to the provider with the ComponentConnector or by using one of the provided React hook.
Below is an example of how to setup the React provider.
import React from 'react';
import ReactDOM from 'react-dom';
import { ObjectiveStoreProvider, ObjectiveStore } from 'objective-redux';
import App from './app';
const objectiveStore = new ObjectiveStore();
ReactDOM.render(
<ObjectiveStoreProvider objectiveStore={objectiveStore}>
// Any child components have access to the store
<App />
</ObjectiveStoreProvider>,
document.getElementById('root')
);
If you are using this with React-Redux, see the Use with React-Redux page for additional instructions.