Open
Description
I need to increase counter by timer, then go to another view goSeeingCounted
to see result for further processing.
Seems recursed timer is unstoppable. Any help?
Example of code to be fixed (playground):
const { div, p, button } = Moon.view.m;
const goSeeingCounted = ({ data }) => {
return {
data,
time: undefined,
view: <viewSeeCounted counter=data.counter/>
};
};
const viewCounter = ({ counter }) => (
<div>
<p>{counter}</p>
<button @click=goSeeingCounted>Create</button>
</div>
);
const viewSeeCounted = ({ counter }) => (
<div>
<p>Result: {counter}</p>
</div>
);
const tick = ({data}) => {
let newData = {
counter: 0
}
if (data !== undefined) {
newData.counter = data.counter + 1;
}
return {
data: newData,
time: { 1000: tick },
view: <viewCounter counter=newData.counter/>
};
}
Moon.use({
data: Moon.data.driver,
time: Moon.time.driver,
view: Moon.view.driver("#root")
});
Moon.run(tick);
Metadata
Metadata
Assignees
Labels
No labels