|
@@ -50,10 +50,11 @@ in the examples). You can build it any way you wish, it has to be able to hold
|
|
all the data _ViewModel_ may need to hold. It can also hold some methods
|
|
all the data _ViewModel_ may need to hold. It can also hold some methods
|
|
for manipulation of these data, which is good for the example, but
|
|
for manipulation of these data, which is good for the example, but
|
|
in real project this should be the responsibility of _Model_.
|
|
in real project this should be the responsibility of _Model_.
|
|
-1. In `initialize`, you should register an `Axon` into _ViewModel_ instance.
|
|
|
|
-It implements the _blackboard_ pattern - in which many external observers
|
|
|
|
-(called specialists) observe the data object (called blackboard),
|
|
|
|
-make partial changes and react to them. Elements of _View_
|
|
|
|
|
|
+1. `Trapped` uses [`Axxord`][axxord] to implement a _blackboard_ pattern - in which
|
|
|
|
+many external observers (called specialists) observe the data object
|
|
|
|
+(called blackboard), make partial changes and react to them. To do that,
|
|
|
|
+you must send `axxord:` to _ViewModel_ instance with an instance of `Axon`
|
|
|
|
+(a blackboard subscription manager) as an argument. Elements of _View_
|
|
are observers of the _ViewModel_ blackboard, as should
|
|
are observers of the _ViewModel_ blackboard, as should
|
|
be the parts of the _Model_ (this way, _Model_ and _View_
|
|
be the parts of the _Model_ (this way, _Model_ and _View_
|
|
are completely decoupled and both see only changes
|
|
are completely decoupled and both see only changes
|
|
@@ -75,11 +76,13 @@ you will only have one, `blackboard` in the examples)
|
|
that are intended to be used (`smalltalk.Trapped._start_([blackboard]);` JavaScript statement
|
|
that are intended to be used (`smalltalk.Trapped._start_([blackboard]);` JavaScript statement
|
|
in HTML page in the examples).
|
|
in HTML page in the examples).
|
|
1. From that point on, you should only modify or watch data of the blackboard
|
|
1. From that point on, you should only modify or watch data of the blackboard
|
|
-using its API. For the example, try this is Counter example:
|
|
|
|
|
|
+using Axxord API. For the example, try this is Counter example:
|
|
`blackboard axes: #((value)) transform: [ :old | console log: old. 2 * old ]`
|
|
`blackboard axes: #((value)) transform: [ :old | console log: old. 2 * old ]`
|
|
or this in the Todo example:
|
|
or this in the Todo example:
|
|
`blackboard axes: #((todos) 1 done) transform: [ :state | state not ]`.
|
|
`blackboard axes: #((todos) 1 done) transform: [ :state | state not ]`.
|
|
|
|
|
|
|
|
+[axxord]: https://lolg.it/herby/Axxord
|
|
|
|
+
|
|
4 `data-trap` attribute
|
|
4 `data-trap` attribute
|
|
====
|
|
====
|
|
|
|
|