Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snapshotState for any JSON serializable data #46

Closed
wants to merge 1 commit into from

Conversation

kasbah
Copy link

@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
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

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
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