Skip to content

Add snapshotState for any JSON serializable data#46

Closed
kasbah wants to merge 1 commit into
geelen:masterfrom
kasbah:keep-state
Closed

Add snapshotState for any JSON serializable data#46
kasbah wants to merge 1 commit into
geelen:masterfrom
kasbah:keep-state

Conversation

@kasbah
Copy link
Copy Markdown

@kasbah kasbah commented Aug 3, 2017

Could be used with Redux for instance:

const store = redux.createStore(reducer, window.snapshotState || initialState)

store.subscribe(() => {
  window.snapshotState = store.getState()
})
  • Can add some documentation if you are interested.

  • It might be better to depend on js-stringify instead of JSON, what do you think?

Could be used with Redux for instance:

```js
const store = redux.createStore(reducer, window.snapshotState || initialState)

store.subscribe(() => {
  window.snapshotState = store.getState()
})
```
@kasbah
Copy link
Copy Markdown
Author

kasbah commented Aug 4, 2017

I just noticed #30 though I haven't caught up with the full discussion there. I still think giving access to a global variable like this goes a long way and is very flexible while keeping things simple. Maybe we should call it something else since you are already adding a window.react_snapshot_state.

@stereobooster
Copy link
Copy Markdown

In react-snap I use a bit different approach instead of state I save any JSON requests in global store window.snapStore[<path>] so when application is loaded it does not need to do network requests for current page. WDYT?

@geelen
Copy link
Copy Markdown
Owner

geelen commented Nov 2, 2017

This got merged with 74f7fc5 but GH didn't pick it up. I've gone and renamed it to window.react_snapshot_state too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants