5 Commits 356cc0f13c ... 16d21f74d9

Author SHA1 Message Date
  Herbert Vojčík 16d21f74d9 Axxord mentioned in Big Picture section. 6 years ago
  Herbert Vojčík f283ff5f4c Remove badges. 6 years ago
  Herbert Vojčík effe5d0118 Axxord usage in README. 6 years ago
  Herbert Vojčík 129fec7575 Refactor former registerIn:. 6 years ago
  Herbert Vojčík 8d53c7d387 PluggableInterest, related simplifications. 6 years ago

+ 10 - 8
README.md

@@ -1,6 +1,5 @@
 1 Introduction
 ====
-[![Travis CI Status](https://secure.travis-ci.org/herby/trapped.png)](https://travis-ci.org/#!/herby/trapped) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/herby/trapped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
 
 Inspired by the idea that was present in AngularJS,
 Trapped is an Amber that creates bidirectional data-biuding
@@ -51,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
 for manipulation of these data, which is good for the example, but
 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
 be the parts of the _Model_ (this way, _Model_ and _View_
 are completely decoupled and both see only changes
@@ -76,10 +76,12 @@ you will only have one, `blackboard` in the examples)
 that are intended to be used (`smalltalk.Trapped._start_([blackboard]);` JavaScript statement
 in HTML page in the examples).
 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:
-`blackboard modify: #((value)) do: [ :old | console log: old. 2 * old ]`
+using Axxord API. For the example, try this is Counter example:
+`blackboard axes: #((value)) transform: [ :old | console log: old. 2 * old ]`
 or this in the Todo example:
-`blackboard modify: #((todos) 1 done) do: [ :state | state not ]`.
+`blackboard axes: #((todos) 1 done) transform: [ :state | state not ]`.
+
+[axxord]: https://lolg.it/herby/Axxord
 
 4 `data-trap` attribute
 ====

+ 3 - 3
example-counter/src/Trapped-Counter.js

@@ -82,8 +82,8 @@ $ctx1.supercall = true,
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.supercall = false;
 //>>excludeEnd("ctx");;
-$recv($recv($globals.SimpleAxon)._new())._registerIn_(self);
 $self["@value"]=(0);
+$self._axxord_($recv($globals.SimpleAxon)._new());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.TrappedCounter)});
@@ -91,10 +91,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "initialize\x0a\x09super initialize.\x0a\x09SimpleAxon new registerIn: self.\x0a\x09value := 0",
+source: "initialize\x0a\x09super initialize.\x0a\x09value := 0.\x0a\x09self axxord: SimpleAxon new",
 referencedClasses: ["SimpleAxon"],
 //>>excludeEnd("ide");
-messageSends: ["initialize", "registerIn:", "new"]
+messageSends: ["initialize", "axxord:", "new"]
 }),
 $globals.TrappedCounter);
 

+ 2 - 2
example-counter/src/Trapped-Counter.st

@@ -28,7 +28,7 @@ increment
 
 initialize
 	super initialize.
-	SimpleAxon new registerIn: self.
-	value := 0
+	value := 0.
+	self axxord: SimpleAxon new
 ! !
 

+ 3 - 3
example-todo/src/Trapped-Todo.js

@@ -88,7 +88,6 @@ $ctx1.supercall = true,
 $ctx1.supercall = false;
 //>>excludeEnd("ctx");;
 axon=$recv($globals.SimpleAxon)._new();
-$recv(axon)._registerIn_(self);
 $recv(axon)._addInterest_($recv($globals.TrappedPosition)._interestOn_block_([["todos"], nil],(function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
@@ -113,6 +112,7 @@ return [$globals.HashedCollection._newFromPairs_(["text","learn trapped","done",
 $self["@title"]="Todo";
 $self["@todoText"]=nil;
 $self["@todos"]=nil;
+$self._axxord_(axon);
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"initialize",{axon:axon},$globals.TrappedTodo)});
@@ -120,10 +120,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "initialize\x0a\x09| axon |\x0a\x09super initialize.\x0a\x0a    axon := SimpleAxon new.\x0a\x09axon registerIn: self.\x0a\x09\x0a\x09axon addInterest: (TrappedPosition\x0a\x09\x09interestOn: #((todos) nil)\x0a\x09\x09block: [ axon changed: #((remaining)) ]).\x0a\x0a    [ self axes: #((todos)) transform: [{\x0a        #{'text'->'learn trapped'. 'done'->true}.\x0a        #{'text'->'build a trapped app'. 'done'->false}\x0a    }]] valueWithTimeout: 2000.\x0a\x0a\x09title := 'Todo'.\x0a\x09todoText := nil.\x0a\x09todos := nil",
+source: "initialize\x0a\x09| axon |\x0a\x09super initialize.\x0a\x0a    axon := SimpleAxon new.\x0a\x09\x0a\x09axon addInterest: (TrappedPosition\x0a\x09\x09interestOn: #((todos) nil)\x0a\x09\x09block: [ axon changed: #((remaining)) ]).\x0a\x0a    [ self axes: #((todos)) transform: [{\x0a        #{'text'->'learn trapped'. 'done'->true}.\x0a        #{'text'->'build a trapped app'. 'done'->false}\x0a    }]] valueWithTimeout: 2000.\x0a\x0a\x09title := 'Todo'.\x0a\x09todoText := nil.\x0a\x09todos := nil.\x0a\x0a\x09self axxord: axon",
 referencedClasses: ["SimpleAxon", "TrappedPosition"],
 //>>excludeEnd("ide");
-messageSends: ["initialize", "new", "registerIn:", "addInterest:", "interestOn:block:", "changed:", "valueWithTimeout:", "axes:transform:"]
+messageSends: ["initialize", "new", "addInterest:", "interestOn:block:", "changed:", "valueWithTimeout:", "axes:transform:", "axxord:"]
 }),
 $globals.TrappedTodo);
 

+ 3 - 2
example-todo/src/Trapped-Todo.st

@@ -84,7 +84,6 @@ initialize
 	super initialize.
 
     axon := SimpleAxon new.
-	axon registerIn: self.
 	
 	axon addInterest: (TrappedPosition
 		interestOn: #((todos) nil)
@@ -97,7 +96,9 @@ initialize
 
 	title := 'Todo'.
 	todoText := nil.
-	todos := nil
+	todos := nil.
+
+	self axxord: axon
 ! !
 
 !TrappedProcessor class methodsFor: '*Trapped-Todo'!

+ 9 - 17
src/Trapped.js

@@ -413,7 +413,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$recv($recv($self._model())._registeredAxon())._addInterest_($recv($self._class())._interestOn_block_($self._path(),(function(){
+$recv($recv($self._model())._axxord())._addInterest_($recv($self._class())._interestOn_block_($self._path(),(function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
@@ -429,10 +429,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aBlock"],
-source: "watch: aBlock\x0a\x09self model registeredAxon addInterest: (self class\x0a\x09\x09interestOn: self path\x0a\x09\x09block: [ self read: aBlock ])",
+source: "watch: aBlock\x0a\x09self model axxord addInterest: (self class\x0a\x09\x09interestOn: self path\x0a\x09\x09block: [ self read: aBlock ])",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["addInterest:", "registeredAxon", "model", "interestOn:block:", "class", "path", "read:"]
+messageSends: ["addInterest:", "axxord", "model", "interestOn:block:", "class", "path", "read:"]
 }),
 $globals.TrappedPosition);
 
@@ -446,7 +446,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$3,$2;
+var $1;
 $1=$recv($recv(anAspect)._notEmpty())._and_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
@@ -457,17 +457,9 @@ return $recv($recv(anAspect)._last())._isNil();
 //>>excludeEnd("ctx");
 }));
 if($core.assert($1)){
-$3=$recv($globals.InterestedThruAxes)._new();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["new"]=1;
-//>>excludeEnd("ctx");
-$2=$recv($3)._aspect_block_($recv(anAspect)._allButLast(),aBlock);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["aspect:block:"]=1;
-//>>excludeEnd("ctx");
-return $2;
+return $recv($globals.Axes)._newInterestThru_doing_($recv(anAspect)._allButLast(),aBlock);
 } else {
-return $recv($recv($globals.InterestedUpToAxes)._new())._aspect_block_(anAspect,aBlock);
+return $recv($globals.Axes)._newInterestUpTo_doing_(anAspect,aBlock);
 }
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -476,10 +468,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anAspect", "aBlock"],
-source: "interestOn: anAspect block: aBlock\x0a\x09(anAspect notEmpty and: [ anAspect last isNil ])\x0a\x09\x09ifTrue: [ ^ InterestedThruAxes new aspect: anAspect allButLast block: aBlock ]\x0a\x09\x09ifFalse: [ ^ InterestedUpToAxes new aspect: anAspect block: aBlock ]",
-referencedClasses: ["InterestedThruAxes", "InterestedUpToAxes"],
+source: "interestOn: anAspect block: aBlock\x0a\x09(anAspect notEmpty and: [ anAspect last isNil ])\x0a\x09\x09ifTrue: [ ^ Axes newInterestThru: anAspect allButLast doing: aBlock ]\x0a\x09\x09ifFalse: [ ^ Axes newInterestUpTo: anAspect doing: aBlock ]",
+referencedClasses: ["Axes"],
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "and:", "notEmpty", "isNil", "last", "aspect:block:", "new", "allButLast"]
+messageSends: ["ifTrue:ifFalse:", "and:", "notEmpty", "isNil", "last", "newInterestThru:doing:", "allButLast", "newInterestUpTo:doing:"]
 }),
 $globals.TrappedPosition.a$cls);
 

+ 3 - 3
src/Trapped.st

@@ -106,7 +106,7 @@ read: aBlock
 !
 
 watch: aBlock
-	self model registeredAxon addInterest: (self class
+	self model axxord addInterest: (self class
 		interestOn: self path
 		block: [ self read: aBlock ])
 ! !
@@ -115,8 +115,8 @@ watch: aBlock
 
 interestOn: anAspect block: aBlock
 	(anAspect notEmpty and: [ anAspect last isNil ])
-		ifTrue: [ ^ InterestedThruAxes new aspect: anAspect allButLast block: aBlock ]
-		ifFalse: [ ^ InterestedUpToAxes new aspect: anAspect block: aBlock ]
+		ifTrue: [ ^ Axes newInterestThru: anAspect allButLast doing: aBlock ]
+		ifFalse: [ ^ Axes newInterestUpTo: anAspect doing: aBlock ]
 ! !
 
 TrappedPosition subclass: #TrappedSnapshot