avaragado / xstateful-react

Use xstateful with React, accessing states and activities from multiple statecharts anywhere in your app
MIT License
30 stars 2 forks source link

Feature: Pass a dispatch function into Machine render #3

Closed ShMcK closed 6 years ago

ShMcK commented 6 years ago

If extstate is to store data much like Redux, should there be a way that this data can be updated without a statechart transition? Would it be a good idea to also pass dispatch into the Machine render method?

avaragado commented 6 years ago

I'm not sure what you mean by dispatch. The consumer components have access to a transition callback, which sends an event to the xstate machine just as Redux dispatch sends an action to Redux reducers.

It's probably a good idea to pass the underlying XStateful instance's setExtState to consumer components too, which would allow them to update extstate as you suggest. I'll do this in the next day or so I hope.

avaragado commented 6 years ago

Added setExtState to consumer components, released in v0.6.0.