Quantcast
Channel: getState in redux-saga? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

getState in redux-saga?

$
0
0

I have a store with a list of items. When my app first loads, I need to deserialize the items, as in create some in-memory objects based on the items. The items are stored in my redux store and handled by an itemsReducer.

I'm trying to use redux-saga to handle the deserialization, as a side effect. On first page load, I dispatch an action:

dispatch( deserializeItems() );

My saga is set up simply:

function* deserialize( action ) {
    // How to getState here??
    yield put({ type: 'DESERISLIZE_COMPLETE' });
}

function* mySaga() {
    yield* takeEvery( 'DESERIALIZE', deserialize );
}

In my deserialize saga, where I want to handle the side effect of creating in-memory versions of my items, I need to read the existing data from the store. I'm not sure how to do that here, or if that's a pattern I should even be attempting with redux-saga.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>