javascript - getState in redux-saga? -


i have store list of items. when app first loads, need deserialize items, in create in-memory objects based on items. items stored in redux store , handled itemsreducer.

i'm trying use redux-saga handle deserialization, side effect. on first page load, dispatch action:

dispatch( deserializeitems() ); 

my saga set simply:

function* deserialize( action ) {     // how getstate here??     yield put({ type: 'deserislize_complete' }); }  function* mysaga() {     yield* takeevery( 'deserialize', deserialize ); } 

in deserialize saga, want handle side effect of creating in-memory versions of items, need read existing data store. i'm not sure how here, or if that's pattern should attempting redux-saga.

you can use select effect

import {select, ...} 'redux-saga/effects'  function* deserialize( action ) {     const state = yield select();     ....     yield put({ type: 'deserislize_complete' }); } 

also can use selectors

const getitems = state => state.items;  function* deserialize( action ) {     const items = yield select(getitems);     ....     yield put({ type: 'deserislize_complete' }); } 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -