-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of initializing split SDK with redux-saga middleware #5
Comments
Hello @manasanavada Currently the Split-Redux SDK does not provide first-class support for redux-saga. import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, applyMiddleware, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import createSagaMiddleware from 'redux-saga'
import { splitReducer, initSplitSdk, getTreatments, getSplitNames } from '@splitsoftware/splitio-redux'
/** Init Redux Store */
const sagaMiddleware = createSagaMiddleware()
const store = createStore(
combineReducers({
splitio: splitReducer,
// other reducers
}),
applyMiddleware(thunk, sagaMiddleware)
);
/** Run your sagas */
sagaMiddleware.run(mySaga);
/** Dispatch `initSplitSdk` to init Split SDK */
store.dispatch(initSplitSdk({
config: SDK_CONFIG,
onReady: () => {
console.log('SDK initialized');
/** Once the SDK is ready, we dispatch a `getTreatments` action with all Splits in our workspace */
const splitNames = getSplitNames();
store.dispatch(getTreatments({ splitNames }));
}
}));
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
); Redux-thunk is a tiny library with a few lines of code. Thus, it doesn't have much impact on your app size. You can also check this branch at our Redux SDK example, where we tested a workaround to use the SDK with redux-saga but not redux-thunk. Consider that this example requires that you pass the store dispatch method when running |
It would be great if the |
Hello,
I'm looking for an example of how to initialize split sdk using redux saga middleware.
Any help would be appreciated
Thanks
The text was updated successfully, but these errors were encountered: