Reactive programming creates an internal mechanism that automatically updates things when a special kind of object* is changed. No need to call functions or subroutines do do that. You change object A, and B is automatically changed too.
* I understand only objects can be reactors(?).
Reactor: is the object that, when changed, triggers the changes in other objects. Created by
make reactor! .
Reactive expression: changes when the reactor changes. Created by
make reactor! & is
This is the most simple program I could think of using reactive programming:
?house house ?fly fly ?bee bee
A reactor can update itself:
?33 35 ?45 47
Be careful not create an endless loop: If a change triggers a change in itself.
copy has the refinement
/deep to reach nested values (blocks within the main block), so does
This program is supposed to repeat what you type on the console, but it does not work:
?house no change ?blue no change
However, if you change to
?house house ?blue blue
This is a command used for creating reactive GUIs. Please look at GUI- Advanced topics.
Cut-and-pasted from the documentation:
Removes all defined reactions, unconditionally.
Checks if an object’s field is a reactive source . If it is, the first reaction found where that object’s field is present as a source, will be returned, otherwise
none is returned.
/target refinement checks if the field is a target instead of a source, and will return the first reaction found targeting that field or
none if none matches.
Outputs a list of registered reactions for debug purposes.