Browse Source

on:hook: instead of low-level add:

Herbert Vojčík 12 years ago
parent
commit
9be574e4db

+ 12 - 0
js/Trapped-Backend.deploy.js

@@ -173,6 +173,18 @@ return self}
 }),
 smalltalk.TrappedDispatcher);
 
+smalltalk.addMethod(
+"_on_hook_",
+smalltalk.method({
+selector: "on:hook:",
+fn: function (path,aBlock){
+var self=this;
+smalltalk.send(self,"_add_",[[true,path,aBlock]]);
+smalltalk.send(self,"_dirty_",[true]);
+return self}
+}),
+smalltalk.TrappedDispatcher);
+
 smalltalk.addMethod(
 "_run",
 smalltalk.method({

+ 17 - 0
js/Trapped-Backend.js

@@ -235,6 +235,23 @@ referencedClasses: []
 }),
 smalltalk.TrappedDispatcher);
 
+smalltalk.addMethod(
+"_on_hook_",
+smalltalk.method({
+selector: "on:hook:",
+category: 'action',
+fn: function (path,aBlock){
+var self=this;
+smalltalk.send(self,"_add_",[[true,path,aBlock]]);
+smalltalk.send(self,"_dirty_",[true]);
+return self},
+args: ["path", "aBlock"],
+source: "on: path hook: aBlock\x0a\x09self add: { true. path. aBlock }.\x0a   \x09self dirty: true",
+messageSends: ["add:", "dirty:"],
+referencedClasses: []
+}),
+smalltalk.TrappedDispatcher);
+
 smalltalk.addMethod(
 "_run",
 smalltalk.method({

+ 2 - 3
js/Trapped-Frontend.deploy.js

@@ -89,10 +89,9 @@ smalltalk.method({
 selector: "watch:do:",
 fn: function (path,aBlock){
 var self=this;
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_add_",[[true,path,(function(){
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_on_hook_",[path,(function(){
 return smalltalk.send(self,"_read_do_",[path,aBlock]);
-})]]);
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_dirty_",[true]);
+})]);
 return self}
 }),
 smalltalk.TrappedModelWrapper);

+ 4 - 5
js/Trapped-Frontend.js

@@ -127,14 +127,13 @@ selector: "watch:do:",
 category: 'action',
 fn: function (path,aBlock){
 var self=this;
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_add_",[[true,path,(function(){
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_on_hook_",[path,(function(){
 return smalltalk.send(self,"_read_do_",[path,aBlock]);
-})]]);
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_dirty_",[true]);
+})]);
 return self},
 args: ["path", "aBlock"],
-source: "watch: path do: aBlock\x0a\x09self dispatcher add: { true. path. [ self read: path do: aBlock ] }.\x0a    self dispatcher dirty: true",
-messageSends: ["add:", "read:do:", "dispatcher", "dirty:"],
+source: "watch: path do: aBlock\x0a\x09self dispatcher on: path hook: [ self read: path do: aBlock ]\x0a",
+messageSends: ["on:hook:", "read:do:", "dispatcher"],
 referencedClasses: []
 }),
 smalltalk.TrappedModelWrapper);

+ 5 - 0
st/Trapped-Backend.st

@@ -109,6 +109,11 @@ dirty: aBoolean
 	aBoolean ifTrue: [[ self run ] fork]
 !
 
+on: path hook: aBlock
+	self add: { true. path. aBlock }.
+   	self dirty: true
+!
+
 run
 	| needsClean |
     needsClean := false.

+ 1 - 2
st/Trapped-Frontend.st

@@ -57,8 +57,7 @@ start
 !
 
 watch: path do: aBlock
-	self dispatcher add: { true. path. [ self read: path do: aBlock ] }.
-    self dispatcher dirty: true
+	self dispatcher on: path hook: [ self read: path do: aBlock ]
 ! !
 
 !TrappedModelWrapper class methodsFor: 'action'!