added #value:withoutNotifying:
authorClaus Gittinger <cg@exept.de>
Fri, 30 Jan 1998 14:24:39 +0100
changeset 796 5aca7d7a8f30
parent 795 f79766570dd7
child 797 bacf790c536d
added #value:withoutNotifying: to avoid recursive updates.
ValModel.st
ValueModel.st
--- a/ValModel.st	Fri Jan 30 14:23:25 1998 +0100
+++ b/ValModel.st	Fri Jan 30 14:24:39 1998 +0100
@@ -88,6 +88,32 @@
     ]
 
     "Modified: 27.3.1997 / 15:14:04 / cg"
+!
+
+value:newValue withoutNotifying:someOne
+    "like #value, but temporarily retract all interrests for someOne
+     (i.e. the value-change will NOT directly send ANY change notification
+      to someOne; we cannot guarantee indirect notifications, though.)
+     Useful if someone is itself depending on the receiver,
+     and wants to avoid recursive update notifications."
+
+    |oldInterests wasDependent|
+
+    [
+        oldInterests := self interestsFor:someOne.
+        self retractInterestsFor:someOne.
+        wasDependent := (self dependents includes:someOne).
+        self removeDependent:someOne.
+        
+        self value:newValue.
+    ] valueNowOrOnUnwindDo:[
+        wasDependent ifTrue:[self addDependent:someOne].
+        oldInterests do:[:i |
+            self addInterest:i
+        ].
+    ].
+
+    "Modified: / 30.1.1998 / 14:14:01 / cg"
 ! !
 
 !ValueModel methodsFor:'converting'!
@@ -119,5 +145,5 @@
 !ValueModel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Attic/ValModel.st,v 1.22 1998-01-27 11:12:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Attic/ValModel.st,v 1.23 1998-01-30 13:24:39 cg Exp $'
 ! !
--- a/ValueModel.st	Fri Jan 30 14:23:25 1998 +0100
+++ b/ValueModel.st	Fri Jan 30 14:24:39 1998 +0100
@@ -88,6 +88,32 @@
     ]
 
     "Modified: 27.3.1997 / 15:14:04 / cg"
+!
+
+value:newValue withoutNotifying:someOne
+    "like #value, but temporarily retract all interrests for someOne
+     (i.e. the value-change will NOT directly send ANY change notification
+      to someOne; we cannot guarantee indirect notifications, though.)
+     Useful if someone is itself depending on the receiver,
+     and wants to avoid recursive update notifications."
+
+    |oldInterests wasDependent|
+
+    [
+        oldInterests := self interestsFor:someOne.
+        self retractInterestsFor:someOne.
+        wasDependent := (self dependents includes:someOne).
+        self removeDependent:someOne.
+        
+        self value:newValue.
+    ] valueNowOrOnUnwindDo:[
+        wasDependent ifTrue:[self addDependent:someOne].
+        oldInterests do:[:i |
+            self addInterest:i
+        ].
+    ].
+
+    "Modified: / 30.1.1998 / 14:14:01 / cg"
 ! !
 
 !ValueModel methodsFor:'converting'!
@@ -119,5 +145,5 @@
 !ValueModel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ValueModel.st,v 1.22 1998-01-27 11:12:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ValueModel.st,v 1.23 1998-01-30 13:24:39 cg Exp $'
 ! !