Angular with Redux

24 views
Skip to first unread message

Sivaprakash Gopal

unread,
Jun 18, 2019, 7:12:53 PM6/18/19
to Angular and AngularJS discussion
Hi All,

I would like to maintain Model object in the browser.

Reason : 
    On navigation of the each screen i can update the model object and will call API after certain navigation. 

Instead of storing into localStorage or sessionStroage, we would like to use Redux to maintain the state of the object. 

Please suggest whether it is good approach to retain it redux store instead of localStorage.

Thanks,
Siva

Sander Elias

unread,
Jun 19, 2019, 3:35:23 AM6/19/19
to Angular and AngularJS discussion
hi Sivaprakash,

You can use redux with Angular no problem there. However, a redux store is an in-memory store that goes empty on reload/refresh of your page.
There is also ngRx store, which has a lot of the same patterns that redux is introducing. 
However, this has a reasonable high buy-in/learning curve (that goes for basically all redux based solutions)
You might want to take a look at the pattern called `observable store` (iirc Dan Whalin` has a blog post on that). That's a load easier to implement/learn.

Regards
Sander

Sivaprakash Gopal

unread,
Jun 20, 2019, 1:39:17 AM6/20/19
to Angular and AngularJS discussion
Sander,

How to maintain data even after refresh the screen 

Thanks,
Siva

Sander Elias

unread,
Jun 20, 2019, 5:24:34 AM6/20/19
to Angular and AngularJS discussion
Hi Siva,

Store it. Local storage and indexdb are the easiest to work with. If you are building a PWA, you might want to use a cache that's available to the service worker. Repopulate your store on startup.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages