I need to add data to localStorage and Redux, how can I do that? Can I use localStorage in a reducer?
Related
Is it possible to determine the last called action in an Angular/Redux project in the code so that I can react on it in the observer? Currently I am using a property in my redux store which is set to the current name of the action in the corresposonging reducer, but is there an easier way to do this?
We currently have such values set in a settings slice;
settingsSlice: {
projectId: 'a'
}
The projectId in the example above is used to compose a dynamic URL that an RTK Query API uses for requests, e.g. https://projectId...
Is it possible to invalidate the API data upon a change to the settings slice?
From the documentation, it seems possible to invalidate other API's using tags, but that doesn't seem to be supported within state slices.
No you would have to manually call dispatch(api.invalidateTags(...)).
Using following example:
https://github.com/zeit/next.js/tree/canary/examples/with-redux-wrapper
After page has been refreshed getInitialProps get called and store get populated with initial state. But only on a server side. When comes to client side store is empty and initial state is passed a prop. Is there a way to set store state with initial state again or what should I do?
You should use redux persist with this example
https://github.com/zeit/next.js/tree/canary/examples/with-redux-persist
I want to StreamProvider to pass my UserData object through out all the widgets, so it can be accessible anywhere.
The UserData object is taken/read from the Firestore database.
My questions are:
How can I use StreamProvider properly/efficiently so it will minimize the widget rebuild and read from Firestore (cause Firebase bills per every document read, CMIIW)?
Should I use FutureProvider instead? But I want the UI also be able to be updated when there is change in the database.
With Provider, you can use Consumer and Selector to avoid unnecessarily rebuilds.
https://pub.dev/documentation/provider/latest/
Using ngrx, I store an observable inside a store, and I get the following error.
this is because I try to store an object of classA with an observable, and that some other class subscribed to it.
My question is, is there a way to avoid circular reference in an observable? or in ngrx to ignore this property ?
Don't store an observable in the store. Your actions and store should be serializable. https://ngrx.io/guide/store#key-concepts