redux-url-sync
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

Redux-url-sync documentation

No other dependencies needed besides redux! This is my first package to create, so be careful :) .

Setting up your store

const reducers = urlCombineReducers({
    test: testReducer,
});
 
export const store = createStore(reducers, {
    test: testInitialState,
    url: urlInitialState,
}, applyMiddleware(thunk as ThunkMiddleware<IRealTestState, AnyAction>, urlMiddleware(updateFromUrl)));
 
subscribeToUrl(store);

Example with redux-thunk

export const setUrlFirstName = (
    firstNamestring
)ThunkAction<void, IRealTestState, undefined, AnyAction=> (dispatch, store) => {
    const lastName = store().test.lastName || '';
    dispatch(setUrlQuery({
        firstName,
        lastName,
    }));
    dispatch(setFirstName(firstName));
};

For more information, see the test project right in this repo.

Package Sidebar

Install

npm i redux-url-sync

Weekly Downloads

9

Version

1.3.2

License

MIT

Unpacked Size

11.1 kB

Total Files

23

Last publish

Collaborators

  • jindra12