-
Notifications
You must be signed in to change notification settings - Fork 45
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
Question: TEA with Reason+React Native #93
Comments
It kind of is by calling out to the react handler from the view (using stateless react views) and just using an empty element as the return value. Not entirely pretty, though it would be easier if I get around to finishing the Custom Element handling in the vdom (patches welcome, or keep pinging me to get it done!) ^.^ I love your avatar, I thought my notification popup broke somehow (especially since it is not a webview)! Lol! I'd be curious to hear about your experiments in it as such? It's definitely a bit of a hack, but is doable! |
This may be asking too much, but would it be terribly time consuming to throw together a super quick example? I'm quite new to this repo as well as Reason. |
I don't use react and don't really know it well enough to use it, but as a start if you look at the example project on the main readme you could replace the view function with something like (this is all in OCaml syntax as that is what I know, but should be trivially changeable to reason as they are pretty close): let view model =
let _ = my_react_call model in
span [] [] Where open Tea
open Tea.App
open Tea.Html
type msg =
| StateUpdate
| Increment
| Decrement
| Reset
| Set of int
type model = {
state : int;
count : int;
}
let init () = {state=0; count=4}, Cmd.none
let update {state; count} = function
| StateUpdate -> {state=state+1; count}, Cmd.none
| Increment -> {state; model=model + 1}, Cmd.none
| Decrement -> {state; model=model - 1}, Cmd.none
| Reset -> {state; model=0}, Cmd.none
| Set v -> {state; model=v}, Cmd.none
let subscriptions {state} =
if state > 2
then Tea.Sub.none
else AnimationFrame.times (fun _ -> StateUpdate)
let view {state; count} =
let _ = if state > 2
then let _ = my_react_call count in () else () in
span [] []
let main =
program {
init;
update;
view;
subscriptions;
shutdown = (fun _model -> Cmd.none); (* Can do something to react here on shutdown if needed *)
} And the react app would inject messages into this If you can setup a repo that I can clone of what you have so far then I can try to PR help in to it too to figure out the best way to handle it all. :-) |
Thanks a ton! This is super helpful. |
This would be really awesome, did you ever get it going? |
I don't use React but a PR would be a good place to contribute missing functionality for it. :-) |
Is it feasible to use bucklescript-tea for handling logic+side-effects and bs-react-native for the view?
Thanks!
The text was updated successfully, but these errors were encountered: