We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Tea.Html.map
If a vdom node switches in place with another node, map does not work as expected
map
I've managed to replicate this in a small example.
open Tea.App open Tea.Html type countUpMsg = Increment type countDownMsg = Decrement type page = | CountUp | CountDown type msg = | SetPage(page) | CountUpMsg(countUpMsg) | CountDownMsg(countDownMsg) type model = (int, page) let init = () => (CountDown, 0) let update = ((page, count), msg) => { switch msg { | SetPage(newPage) => (newPage, count) | CountUpMsg(subMsg) => switch subMsg { | Increment => (page, count + 1) } | CountDownMsg(subMsg) => switch subMsg { | Decrement => (page, count - 1) } } } let viewButton = (~title, ~disabled=false, ~msg, ()) => button(list{Events.onClick(msg), Attributes.disabled(disabled)}, list{text(title)}) let view = ((page, count)) => div(list{}, list{ h3(list{}, list{text("Count: " ++ string_of_int(count))}), viewButton(~title="Count Up", ~msg=SetPage(CountUp), ~disabled=page == CountUp, ()), viewButton(~title="Count Down", ~msg=SetPage(CountDown), ~disabled=page == CountDown, ()), switch page { | CountUp => Tea.Html.map(msg => CountUpMsg(msg), viewButton(~title="Increment", ~msg=Increment, ())) | CountDown => Tea.Html.map(msg => CountDownMsg(msg), viewButton(~title="Decrement", ~msg=Decrement, ())) }, } ) let main = beginnerProgram({ model: init(), update, view })
The text was updated successfully, but these errors were encountered:
I looked at the code and this seems complicated. If you've any idea how to solve it, we'd certainly take the patch.
Sorry, something went wrong.
No branches or pull requests
If a vdom node switches in place with another node,
map
does not work as expectedI've managed to replicate this in a small example.
The text was updated successfully, but these errors were encountered: