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

render callbacks + record/replay #106

Closed
threepointone opened this issue Jun 16, 2015 · 3 comments
Closed

render callbacks + record/replay #106

threepointone opened this issue Jun 16, 2015 · 3 comments

Comments

@threepointone
Copy link

I'll get straight to it, will dive into more details if you need.

boring example 1 - local state

class Counter{
  render(){
    return <State initial={0}>{
      (val, set) =>
        <div onClick={() => set(val + 1)}>
          clicked {val} times
        </div>
    }</State>;
  }
}

all state changes with set() will not be reflected while replaying, BUT because it's 'local', you'd still 'start' and 'end' at the correct states.

boring example 2, spring animations

<Spring to={10}>
  {val => <div>{val}</div>}       
</Spring>

this works fine! it might be dicey if you use onSpringUpdate to update something globally AND your timer goes out of sync. Didn't see it happen with simple examples.

boring example 3

<Ajax url='my/ajax/url'>{
   {results => !results ? 'loading...' : `fetched ${results.length} results`}
}</Ajax>

this is tricky. lets say while recording, the request took 2 seconds, and on the 3rd second you did something to change global state based on this. then when replaying, if the request takes 5 seconds, then Putin conquers your apartment with babooshkas. (this is a similar problem to firing ajax requests in stores and trying to do record/replay)

So yeah, it's obvious that issues like this would come up, because 'replay flux' requires state to be managed centrally. That said, this is better than I expected, and I'm happy to recognize the limitations.

cheers!

@gaearon
Copy link
Contributor

gaearon commented Jun 16, 2015

Record/replay is totally limited to the global state. Surely it won't play nice with the local state. Things like AJAX requests are supposed to be done in Action Creators in Redux, so record/replay won't cause them again.

@threepointone
Copy link
Author

Yes, absolutely.

Now, THAT said, there might be a hack here somewhere to be discovered. It strikes me that if these childfn's 'obtained' their state from the global state (atom/cursor/whatever), and then calling set() on these stores get registered into your action queue, then... something. I don't know yet.

@gaearon
Copy link
Contributor

gaearon commented Jun 17, 2015

Closing as not a real issue with Redux, but I'm open to discussing further here.

@gaearon gaearon closed this as completed Jun 17, 2015
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

No branches or pull requests

2 participants