Browse Source

TrappedMW{Direct,Isolated} in frontend; demo lighter.

Herbert Vojčík 12 years ago
parent
commit
e8ab52ec5d
6 changed files with 334 additions and 257 deletions
  1. 22 66
      js/Trapped-Demo.deploy.js
  2. 27 86
      js/Trapped-Demo.js
  3. 90 22
      js/Trapped-Frontend.deploy.js
  4. 123 33
      js/Trapped-Frontend.js
  5. 15 38
      st/Trapped-Demo.st
  6. 57 12
      st/Trapped-Frontend.st

+ 22 - 66
js/Trapped-Demo.deploy.js

@@ -1,4 +1,26 @@
 smalltalk.addPackage('Trapped-Demo', {});
+smalltalk.addClass('App', smalltalk.TrappedMWIsolated, [], 'Trapped-Demo');
+smalltalk.addMethod(
+"_initialize",
+smalltalk.method({
+selector: "initialize",
+fn: function (){
+var self=this;
+var obj;
+smalltalk.send(self,"_initialize",[],smalltalk.TrappedMWIsolated);
+smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
+obj=smalltalk.HashedCollection._fromPairs_([smalltalk.send("title","__minus_gt",["To-Do List"])]);
+smalltalk.send(self,"_model_",[obj]);
+smalltalk.send((function(){
+smalltalk.send(obj,"_at_put_",["items",["hello", "world"]]);
+return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[[]]);
+}),"_valueWithTimeout_",[(2000)]);
+return self}
+}),
+smalltalk.App);
+
+
+
 smalltalk.addClass('AppView', smalltalk.Widget, [], 'Trapped-Demo');
 smalltalk.addMethod(
 "_renderOn_",
@@ -80,69 +102,3 @@ smalltalk.TrappedDumbDispatcher);
 
 
 
-smalltalk.addClass('TrappedPlainModel', smalltalk.TrappedModelWrapper, [], 'Trapped-Demo');
-smalltalk.addMethod(
-"_initialize",
-smalltalk.method({
-selector: "initialize",
-fn: function (){
-var self=this;
-smalltalk.send(self,"_initialize",[],smalltalk.TrappedModelWrapper);
-smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
-return self}
-}),
-smalltalk.TrappedPlainModel);
-
-smalltalk.addMethod(
-"_modify_do_",
-smalltalk.method({
-selector: "modify:do:",
-fn: function (path,aBlock){
-var self=this;
-var newValue;
-var eavModel;
-eavModel=smalltalk.send(path,"_asEavModel",[]);
-newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
-smalltalk.send((function(){
-return smalltalk.send(eavModel,"_on_put_",[smalltalk.send(self,"_payload",[]),newValue]);
-}),"_ensure_",[(function(){
-return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
-})]);
-return self}
-}),
-smalltalk.TrappedPlainModel);
-
-smalltalk.addMethod(
-"_read_do_",
-smalltalk.method({
-selector: "read:do:",
-fn: function (path,aBlock){
-var self=this;
-var eavModel;
-eavModel=smalltalk.send(path,"_asEavModel",[]);
-smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
-return self}
-}),
-smalltalk.TrappedPlainModel);
-
-
-
-smalltalk.addClass('App', smalltalk.TrappedPlainModel, [], 'Trapped-Demo');
-smalltalk.addMethod(
-"_initialize",
-smalltalk.method({
-selector: "initialize",
-fn: function (){
-var self=this;
-smalltalk.send(self,"_initialize",[],smalltalk.TrappedPlainModel);
-smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("title","__minus_gt",["To-Do List"])])]);
-smalltalk.send((function(){
-smalltalk.send(smalltalk.send(self,"_payload",[]),"_at_put_",["items",["hello", "world"]]);
-return smalltalk.send(self,"_payload_",[smalltalk.send(self,"_payload",[])]);
-}),"_valueWithTimeout_",[(2000)]);
-return self}
-}),
-smalltalk.App);
-
-
-

+ 27 - 86
js/Trapped-Demo.js

@@ -1,4 +1,31 @@
 smalltalk.addPackage('Trapped-Demo', {});
+smalltalk.addClass('App', smalltalk.TrappedMWIsolated, [], 'Trapped-Demo');
+smalltalk.addMethod(
+"_initialize",
+smalltalk.method({
+selector: "initialize",
+category: 'initialization',
+fn: function (){
+var self=this;
+var obj;
+smalltalk.send(self,"_initialize",[],smalltalk.TrappedMWIsolated);
+smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
+obj=smalltalk.HashedCollection._fromPairs_([smalltalk.send("title","__minus_gt",["To-Do List"])]);
+smalltalk.send(self,"_model_",[obj]);
+smalltalk.send((function(){
+smalltalk.send(obj,"_at_put_",["items",["hello", "world"]]);
+return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[[]]);
+}),"_valueWithTimeout_",[(2000)]);
+return self},
+args: [],
+source: "initialize\x0a\x09| obj |\x0a\x09super initialize.\x0a    self dispatcher: TrappedDumbDispatcher new.\x0a    obj := #{'title' -> 'To-Do List'}.\x0a    self model: obj.\x0a    [ obj at: 'items' put: #('hello' 'world'). self dispatcher changed: #() ] valueWithTimeout: 2000\x0a",
+messageSends: ["initialize", "dispatcher:", "new", "->", "model:", "valueWithTimeout:", "at:put:", "changed:", "dispatcher"],
+referencedClasses: ["TrappedDumbDispatcher"]
+}),
+smalltalk.App);
+
+
+
 smalltalk.addClass('AppView', smalltalk.Widget, [], 'Trapped-Demo');
 smalltalk.addMethod(
 "_renderOn_",
@@ -105,89 +132,3 @@ smalltalk.TrappedDumbDispatcher);
 
 
 
-smalltalk.addClass('TrappedPlainModel', smalltalk.TrappedModelWrapper, [], 'Trapped-Demo');
-smalltalk.addMethod(
-"_initialize",
-smalltalk.method({
-selector: "initialize",
-category: 'initialization',
-fn: function (){
-var self=this;
-smalltalk.send(self,"_initialize",[],smalltalk.TrappedModelWrapper);
-smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
-return self},
-args: [],
-source: "initialize\x0a\x09super initialize.\x0a    self dispatcher: TrappedDumbDispatcher new",
-messageSends: ["initialize", "dispatcher:", "new"],
-referencedClasses: ["TrappedDumbDispatcher"]
-}),
-smalltalk.TrappedPlainModel);
-
-smalltalk.addMethod(
-"_modify_do_",
-smalltalk.method({
-selector: "modify:do:",
-category: 'action',
-fn: function (path,aBlock){
-var self=this;
-var newValue;
-var eavModel;
-eavModel=smalltalk.send(path,"_asEavModel",[]);
-newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
-smalltalk.send((function(){
-return smalltalk.send(eavModel,"_on_put_",[smalltalk.send(self,"_payload",[]),newValue]);
-}),"_ensure_",[(function(){
-return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
-})]);
-return self},
-args: ["path", "aBlock"],
-source: "modify: path do: aBlock\x0a    | newValue eavModel |\x0a    eavModel := path asEavModel.\x0a    newValue := aBlock value: (eavModel on: self payload).\x0a    [ eavModel on: self payload put: newValue ] ensure: [ self dispatcher changed: path ]\x0a",
-messageSends: ["asEavModel", "value:", "on:", "payload", "ensure:", "changed:", "dispatcher", "on:put:"],
-referencedClasses: []
-}),
-smalltalk.TrappedPlainModel);
-
-smalltalk.addMethod(
-"_read_do_",
-smalltalk.method({
-selector: "read:do:",
-category: 'action',
-fn: function (path,aBlock){
-var self=this;
-var eavModel;
-eavModel=smalltalk.send(path,"_asEavModel",[]);
-smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
-return self},
-args: ["path", "aBlock"],
-source: "read: path do: aBlock\x0a    | eavModel |\x0a    eavModel := path asEavModel.\x0a    aBlock value: (eavModel on: self payload)\x0a",
-messageSends: ["asEavModel", "value:", "on:", "payload"],
-referencedClasses: []
-}),
-smalltalk.TrappedPlainModel);
-
-
-
-smalltalk.addClass('App', smalltalk.TrappedPlainModel, [], 'Trapped-Demo');
-smalltalk.addMethod(
-"_initialize",
-smalltalk.method({
-selector: "initialize",
-category: 'initialization',
-fn: function (){
-var self=this;
-smalltalk.send(self,"_initialize",[],smalltalk.TrappedPlainModel);
-smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("title","__minus_gt",["To-Do List"])])]);
-smalltalk.send((function(){
-smalltalk.send(smalltalk.send(self,"_payload",[]),"_at_put_",["items",["hello", "world"]]);
-return smalltalk.send(self,"_payload_",[smalltalk.send(self,"_payload",[])]);
-}),"_valueWithTimeout_",[(2000)]);
-return self},
-args: [],
-source: "initialize\x0a\x09super initialize.\x0a\x09self payload: #{'title' -> 'To-Do List'}.\x0a    [ self payload at: 'items' put: #('hello' 'world'). self payload: self payload ] valueWithTimeout: 2000\x0a",
-messageSends: ["initialize", "payload:", "->", "valueWithTimeout:", "at:put:", "payload"],
-referencedClasses: []
-}),
-smalltalk.App);
-
-
-

+ 90 - 22
js/Trapped-Frontend.deploy.js

@@ -56,41 +56,30 @@ return self}
 smalltalk.TrappedModelWrapper);
 
 smalltalk.addMethod(
-"_name",
+"_model_",
 smalltalk.method({
-selector: "name",
-fn: function (){
+selector: "model:",
+fn: function (anObject){
 var self=this;
-var $1;
-$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
-return $1;
-}
+self["@payload"]=anObject;
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[[]]);
+return self}
 }),
 smalltalk.TrappedModelWrapper);
 
 smalltalk.addMethod(
-"_payload",
+"_name",
 smalltalk.method({
-selector: "payload",
+selector: "name",
 fn: function (){
 var self=this;
-return self["@payload"];
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
+return $1;
 }
 }),
 smalltalk.TrappedModelWrapper);
 
-smalltalk.addMethod(
-"_payload_",
-smalltalk.method({
-selector: "payload:",
-fn: function (anObject){
-var self=this;
-self["@payload"]=anObject;
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[[]]);
-return self}
-}),
-smalltalk.TrappedModelWrapper);
-
 smalltalk.addMethod(
 "_start",
 smalltalk.method({
@@ -133,6 +122,85 @@ return $1;
 smalltalk.TrappedModelWrapper.klass);
 
 
+smalltalk.addClass('TrappedMWDirect', smalltalk.TrappedModelWrapper, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_modify_do_",
+smalltalk.method({
+selector: "modify:do:",
+fn: function (path,aBlock){
+var self=this;
+var newValue;
+var eavModel;
+eavModel=smalltalk.send(path,"_asEavModel",[]);
+newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[self["@payload"]])]);
+smalltalk.send((function(){
+return smalltalk.send(eavModel,"_on_put_",[self["@payload"],newValue]);
+}),"_ensure_",[(function(){
+return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
+})]);
+return self}
+}),
+smalltalk.TrappedMWDirect);
+
+smalltalk.addMethod(
+"_read_do_",
+smalltalk.method({
+selector: "read:do:",
+fn: function (path,aBlock){
+var self=this;
+var eavModel;
+eavModel=smalltalk.send(path,"_asEavModel",[]);
+smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[self["@payload"]])]);
+return self}
+}),
+smalltalk.TrappedMWDirect);
+
+
+
+smalltalk.addClass('TrappedMWIsolated', smalltalk.TrappedModelWrapper, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_model_",
+smalltalk.method({
+selector: "model:",
+fn: function (anObject){
+var self=this;
+smalltalk.send(self,"_model_",[smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[anObject])],smalltalk.TrappedModelWrapper);
+return self}
+}),
+smalltalk.TrappedMWIsolated);
+
+smalltalk.addMethod(
+"_modify_do_",
+smalltalk.method({
+selector: "modify:do:",
+fn: function (path,aBlock){
+var self=this;
+var eavModel;
+eavModel=smalltalk.send(smalltalk.send([smalltalk.symbolFor("root")],"__comma",[path]),"_asEavModel",[]);
+smalltalk.send((function(){
+return smalltalk.send(self["@payload"],"_model_modify_",[eavModel,aBlock]);
+}),"_ensure_",[(function(){
+return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
+})]);
+return self}
+}),
+smalltalk.TrappedMWIsolated);
+
+smalltalk.addMethod(
+"_read_do_",
+smalltalk.method({
+selector: "read:do:",
+fn: function (path,aBlock){
+var self=this;
+var eavModel;
+eavModel=smalltalk.send(smalltalk.send([smalltalk.symbolFor("root")],"__comma",[path]),"_asEavModel",[]);
+smalltalk.send(self["@payload"],"_model_read_",[eavModel,aBlock]);
+return self}
+}),
+smalltalk.TrappedMWIsolated);
+
+
+
 smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_start",

+ 123 - 33
js/Trapped-Frontend.js

@@ -45,7 +45,7 @@ smalltalk.TrappedDumbView);
 
 
 smalltalk.addClass('TrappedModelWrapper', smalltalk.Object, ['dispatcher', 'payload'], 'Trapped-Frontend');
-smalltalk.TrappedModelWrapper.comment="I am base class for model wrappers.\x0aI wrap a model which can be any object.\x0a\x0aMy subclasses need to provide implementation for:\x0a\x09read:do:\x0a    modify:do:\x0a\x09(optionally) name\x0a\x0aand must initialize:\x0a\x09payload\x0a\x09dispatcher (with a subclass of TrappedDispatcher)\x0a"
+smalltalk.TrappedModelWrapper.comment="I am base class for model wrappers.\x0aI wrap a model which can be any object.\x0a\x0aMy subclasses need to provide implementation for:\x0a\x09read:do:\x0a    modify:do:\x0a\x09(optionally) name\x0a\x0aand must issue these call when initializing:\x0a\x09model:\x0a\x09dispatcher: (with a subclass of TrappedDispatcher)\x0a"
 smalltalk.addMethod(
 "_dispatcher",
 smalltalk.method({
@@ -79,52 +79,36 @@ referencedClasses: []
 smalltalk.TrappedModelWrapper);
 
 smalltalk.addMethod(
-"_name",
+"_model_",
 smalltalk.method({
-selector: "name",
+selector: "model:",
 category: 'accessing',
-fn: function (){
+fn: function (anObject){
 var self=this;
-var $1;
-$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
-return $1;
-},
-args: [],
-source: "name\x0a\x09^ self class name",
-messageSends: ["name", "class"],
+self["@payload"]=anObject;
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[[]]);
+return self},
+args: ["anObject"],
+source: "model: anObject\x0a\x09payload := anObject.\x0a    self dispatcher changed: #()",
+messageSends: ["changed:", "dispatcher"],
 referencedClasses: []
 }),
 smalltalk.TrappedModelWrapper);
 
 smalltalk.addMethod(
-"_payload",
+"_name",
 smalltalk.method({
-selector: "payload",
+selector: "name",
 category: 'accessing',
 fn: function (){
 var self=this;
-return self["@payload"];
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
+return $1;
 },
 args: [],
-source: "payload\x0a\x09^payload",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_payload_",
-smalltalk.method({
-selector: "payload:",
-category: 'accessing',
-fn: function (anObject){
-var self=this;
-self["@payload"]=anObject;
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[[]]);
-return self},
-args: ["anObject"],
-source: "payload: anObject\x0a\x09payload := anObject.\x0a    self dispatcher changed: #()",
-messageSends: ["changed:", "dispatcher"],
+source: "name\x0a\x09^ self class name",
+messageSends: ["name", "class"],
 referencedClasses: []
 }),
 smalltalk.TrappedModelWrapper);
@@ -186,6 +170,112 @@ referencedClasses: []
 smalltalk.TrappedModelWrapper.klass);
 
 
+smalltalk.addClass('TrappedMWDirect', smalltalk.TrappedModelWrapper, [], 'Trapped-Frontend');
+smalltalk.TrappedMWDirect.comment="I am TrappedModelWrapper that directly manipulate\x0athe object passed to model:"
+smalltalk.addMethod(
+"_modify_do_",
+smalltalk.method({
+selector: "modify:do:",
+category: 'action',
+fn: function (path,aBlock){
+var self=this;
+var newValue;
+var eavModel;
+eavModel=smalltalk.send(path,"_asEavModel",[]);
+newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[self["@payload"]])]);
+smalltalk.send((function(){
+return smalltalk.send(eavModel,"_on_put_",[self["@payload"],newValue]);
+}),"_ensure_",[(function(){
+return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
+})]);
+return self},
+args: ["path", "aBlock"],
+source: "modify: path do: aBlock\x0a    | newValue eavModel |\x0a    eavModel := path asEavModel.\x0a    newValue := aBlock value: (eavModel on: payload).\x0a    [ eavModel on: payload put: newValue ] ensure: [ self dispatcher changed: path ]\x0a",
+messageSends: ["asEavModel", "value:", "on:", "ensure:", "changed:", "dispatcher", "on:put:"],
+referencedClasses: []
+}),
+smalltalk.TrappedMWDirect);
+
+smalltalk.addMethod(
+"_read_do_",
+smalltalk.method({
+selector: "read:do:",
+category: 'action',
+fn: function (path,aBlock){
+var self=this;
+var eavModel;
+eavModel=smalltalk.send(path,"_asEavModel",[]);
+smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[self["@payload"]])]);
+return self},
+args: ["path", "aBlock"],
+source: "read: path do: aBlock\x0a    | eavModel |\x0a    eavModel := path asEavModel.\x0a    aBlock value: (eavModel on: payload)\x0a",
+messageSends: ["asEavModel", "value:", "on:"],
+referencedClasses: []
+}),
+smalltalk.TrappedMWDirect);
+
+
+
+smalltalk.addClass('TrappedMWIsolated', smalltalk.TrappedModelWrapper, [], 'Trapped-Frontend');
+smalltalk.TrappedMWIsolated.comment="I am TrappedModelWrapper than wrap access\x0ato an object passed to model: via Isolator."
+smalltalk.addMethod(
+"_model_",
+smalltalk.method({
+selector: "model:",
+category: 'accessing',
+fn: function (anObject){
+var self=this;
+smalltalk.send(self,"_model_",[smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[anObject])],smalltalk.TrappedModelWrapper);
+return self},
+args: ["anObject"],
+source: "model: anObject\x0a\x09super model: (Isolator on: anObject)",
+messageSends: ["model:", "on:"],
+referencedClasses: ["Isolator"]
+}),
+smalltalk.TrappedMWIsolated);
+
+smalltalk.addMethod(
+"_modify_do_",
+smalltalk.method({
+selector: "modify:do:",
+category: 'action',
+fn: function (path,aBlock){
+var self=this;
+var eavModel;
+eavModel=smalltalk.send(smalltalk.send([smalltalk.symbolFor("root")],"__comma",[path]),"_asEavModel",[]);
+smalltalk.send((function(){
+return smalltalk.send(self["@payload"],"_model_modify_",[eavModel,aBlock]);
+}),"_ensure_",[(function(){
+return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
+})]);
+return self},
+args: ["path", "aBlock"],
+source: "modify: path do: aBlock\x0a    | eavModel |\x0a    eavModel := ({#root},path) asEavModel.\x0a    [ payload model: eavModel modify: aBlock ] ensure: [ self dispatcher changed: path ]\x0a",
+messageSends: ["asEavModel", ",", "ensure:", "changed:", "dispatcher", "model:modify:"],
+referencedClasses: []
+}),
+smalltalk.TrappedMWIsolated);
+
+smalltalk.addMethod(
+"_read_do_",
+smalltalk.method({
+selector: "read:do:",
+category: 'action',
+fn: function (path,aBlock){
+var self=this;
+var eavModel;
+eavModel=smalltalk.send(smalltalk.send([smalltalk.symbolFor("root")],"__comma",[path]),"_asEavModel",[]);
+smalltalk.send(self["@payload"],"_model_read_",[eavModel,aBlock]);
+return self},
+args: ["path", "aBlock"],
+source: "read: path do: aBlock\x0a    | eavModel |\x0a    eavModel := ({#root},path) asEavModel.\x0a    payload model: eavModel read: aBlock\x0a",
+messageSends: ["asEavModel", ",", "model:read:"],
+referencedClasses: []
+}),
+smalltalk.TrappedMWIsolated);
+
+
+
 smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_start",

+ 15 - 38
st/Trapped-Demo.st

@@ -1,4 +1,19 @@
 Smalltalk current createPackage: 'Trapped-Demo' properties: #{}!
+TrappedMWIsolated subclass: #App
+	instanceVariableNames: ''
+	package: 'Trapped-Demo'!
+
+!App methodsFor: 'initialization'!
+
+initialize
+	| obj |
+	super initialize.
+    self dispatcher: TrappedDumbDispatcher new.
+    obj := #{'title' -> 'To-Do List'}.
+    self model: obj.
+    [ obj at: 'items' put: #('hello' 'world'). self dispatcher changed: #() ] valueWithTimeout: 2000
+! !
+
 Widget subclass: #AppView
 	instanceVariableNames: ''
 	package: 'Trapped-Demo'!
@@ -46,41 +61,3 @@ initialize
 	queue := OrderedCollection new
 ! !
 
-TrappedModelWrapper subclass: #TrappedPlainModel
-	instanceVariableNames: ''
-	package: 'Trapped-Demo'!
-
-!TrappedPlainModel methodsFor: 'action'!
-
-modify: path do: aBlock
-    | newValue eavModel |
-    eavModel := path asEavModel.
-    newValue := aBlock value: (eavModel on: self payload).
-    [ eavModel on: self payload put: newValue ] ensure: [ self dispatcher changed: path ]
-!
-
-read: path do: aBlock
-    | eavModel |
-    eavModel := path asEavModel.
-    aBlock value: (eavModel on: self payload)
-! !
-
-!TrappedPlainModel methodsFor: 'initialization'!
-
-initialize
-	super initialize.
-    self dispatcher: TrappedDumbDispatcher new
-! !
-
-TrappedPlainModel subclass: #App
-	instanceVariableNames: ''
-	package: 'Trapped-Demo'!
-
-!App methodsFor: 'initialization'!
-
-initialize
-	super initialize.
-	self payload: #{'title' -> 'To-Do List'}.
-    [ self payload at: 'items' put: #('hello' 'world'). self payload: self payload ] valueWithTimeout: 2000
-! !
-

+ 57 - 12
st/Trapped-Frontend.st

@@ -43,9 +43,9 @@ My subclasses need to provide implementation for:
     modify:do:
 	(optionally) name
 
-and must initialize:
-	payload
-	dispatcher (with a subclass of TrappedDispatcher)!
+and must issue these call when initializing:
+	model:
+	dispatcher: (with a subclass of TrappedDispatcher)!
 
 !TrappedModelWrapper methodsFor: 'accessing'!
 
@@ -57,17 +57,13 @@ dispatcher: aDispatcher
 	dispatcher := aDispatcher
 !
 
-name
-	^ self class name
-!
-
-payload
-	^payload
-!
-
-payload: anObject
+model: anObject
 	payload := anObject.
     self dispatcher changed: #()
+!
+
+name
+	^ self class name
 ! !
 
 !TrappedModelWrapper methodsFor: 'action'!
@@ -86,6 +82,55 @@ start
 	^self new start; yourself
 ! !
 
+TrappedModelWrapper subclass: #TrappedMWDirect
+	instanceVariableNames: ''
+	package: 'Trapped-Frontend'!
+!TrappedMWDirect commentStamp!
+I am TrappedModelWrapper that directly manipulate
+the object passed to model:!
+
+!TrappedMWDirect methodsFor: 'action'!
+
+modify: path do: aBlock
+    | newValue eavModel |
+    eavModel := path asEavModel.
+    newValue := aBlock value: (eavModel on: payload).
+    [ eavModel on: payload put: newValue ] ensure: [ self dispatcher changed: path ]
+!
+
+read: path do: aBlock
+    | eavModel |
+    eavModel := path asEavModel.
+    aBlock value: (eavModel on: payload)
+! !
+
+TrappedModelWrapper subclass: #TrappedMWIsolated
+	instanceVariableNames: ''
+	package: 'Trapped-Frontend'!
+!TrappedMWIsolated commentStamp!
+I am TrappedModelWrapper than wrap access
+to an object passed to model: via Isolator.!
+
+!TrappedMWIsolated methodsFor: 'accessing'!
+
+model: anObject
+	super model: (Isolator on: anObject)
+! !
+
+!TrappedMWIsolated methodsFor: 'action'!
+
+modify: path do: aBlock
+    | eavModel |
+    eavModel := ({#root},path) asEavModel.
+    [ payload model: eavModel modify: aBlock ] ensure: [ self dispatcher changed: path ]
+!
+
+read: path do: aBlock
+    | eavModel |
+    eavModel := ({#root},path) asEavModel.
+    payload model: eavModel read: aBlock
+! !
+
 Object subclass: #TrappedSingleton
 	instanceVariableNames: ''
 	package: 'Trapped-Frontend'!