btroncone / ngrx-examples

@ngrx examples and resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autosave feature in ngrx store

moniuch opened this issue · comments

commented

I would love to see an example of an auto-save feature implementation in ngrx store that would satisfy the following scenario:

(Let's say we have an app that allows users to store/retrieve their own html code.)

  • /page1 loads and pulls up user html from service, then displays it in a textarea
  • user edits the code
  • user switches to /page2
  • user switches back to /page1 and should see their html in its latest state
  • by auto-save I mean just internal persistence, rather than real saving to db. The latter would be done on an explicit button click.

The path I think I would take would be to store the html as well as the loaded flag in the state, and when page1 loads, load the html only if "loaded" flag is false. But I don't know where to place this "if" test.

Anyway, a complete example (Angular2, TS) would be nice.