Closed teh closed 8 years ago
Did you see that createReactSpec
already returns a driver function?
https://github.com/paf31/purescript-thermite/blob/master/docs/Thermite.md#createreactspec
Thanks. Yea, that's what I'm using, here's some (ugly) code where I extract the dispatcher
:
let validatedInputSpec = T.createReactSpec validatedInput initialState
let component = R.createClass ((_.spec validatedInputSpec) { componentDidMount = (componentDidMount (_.dispatcher validatedInputSpec))})
let reactElement = (R.createFactory component {})
AFAICT the dispatcher needs a ReactThis
which I can only get out from within react (e.g. after component mounting).
So this isn't a case of "not possible" but I was wondering whether we could make the API nicer.
After more reflection I guess it's going to be hard because we need the specific component for which to dispatch actions. I could add a helper Thermite.createElement
that returns a dispatcher bound to ReactThis
but that seems overkill.
Created a helper that returns the correctly bound dispatcher but I think it's a bit too specific to be included in Thermite. Closing.
Hi,
I'm currently combining purescript-routing and thermite with a bit of code like the following to dispatch events into the root component:
This works but isn't particularly beautiful. I was wondering if you have an idea / interest for how to add a halogen
driver
(https://github.com/slamdata/purescript-halogen/blob/v0.5.14/docs/Halogen/Driver.md) like function?