All examples · State and scripts

Scripts that compose

What this example shows

Three behaviours on one object, in three files, with no import between them. Two only share the object: spin turns it and breathe resizes it, and neither knows the other exists. The third needs to call into one, which sharing the object does not cover, so spin publishes a way to be stopped with provide and toggle reaches it with useApi. Press Space.

Read the order in index.ts. The consumer is attached before the publisher, and it works anyway: useApi hands back a way to ask rather than the answer, so the question is asked once everything is running and the order of two lines cannot decide whether it works. requires: ['spin'] is the half of that relationship a tool can read: it reports, and never stops a behaviour from running.

Starting