Rule 183p-update
Comments
This is the only rule that takes a message from the queue or changes the model. The message at the head of the queue is applied, with the model, to update; the commands of the result are dispatched, and the subscriptions recomputed from the new model, whether or not it has changed, all in the one step. If the application of update has no result (it reaches Debug.todo), the rule never applies again, and no further message is handled, though processes, ports and the platform go on taking steps.
Referred to from
TeX source
\defnrule[r:p-update]
{\japp{r(\kw{update})}{v_1}{v_2}\premsep\japp{v_2}{v}{(v',\cm)}\\
\effFlat(\cm)=\effmset{\effc_1,\ldots,\effc_n}\premsep
\jdg{s,P,Q,H}{\effc_1\cdots\effc_n}{(P',Q',H')}\\
\japp{r(\kw{subscriptions})}{v'}{\sbv'}}
{(s,v,v_1\cdot M,P,\sbv,Q,H)\step{}(s,v',M,P',\sbv',Q',H')}Tests (5)
- elm / CoreIssue1141UnusedPortCallBreaksSubscriptionTestAn unused port call (`_ = echoOut "unused"` in `init`) breaks a port subscription elsewhere.
- elm / MinimalTaskPerformTestThe message of a performed task reaches update.
- elm-core / CoreIssue1110PortDeclarationOrderTestA subscription returned together with a port command is active in time to receive that command's synchronous reply.
- elm-core / CoreIssue1154PortSubscribedWithCmdTestA port subscription added by the same `update` that sends a command to an outgoing port misses the outgoing port's synchronous reply, depending on the order of the ports in the generated code.
- elm-core / TimerEffectTestA `Platform.worker` that chains `Process.sleep` timers through `Task.perform` receives each timer message in turn and stops after five.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:p-update] in its title.
A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.