Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stlutz committed Jan 17, 2018
2 parents 163b4af + 6d4806b commit ffbed60
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
change detection
disable

self uninstallMonitors.
self disableAllCallbacks
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
change detection
enable

self updateMonitors.
self enableAllCallbacks
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ initialize-release
initialize

super initialize.
self setLastValue: self currentValue
self setLastValue: self currentValue.
self installMonitors
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
change detection
installMonitors

| instVarsToMonitor |
instVarsToMonitor := self instVarsToMonitor.
self monitorInstVars: instVarsToMonitor.
self monitoredInstVars: instVarsToMonitor.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
change detection
monitorInstVars: objectInstVarsDict

objectInstVarsDict keysAndValuesDo: [:object :instVars |
instVars do: [:instVar | object
onChangeOfInstVarNamed: instVar
notify: self
using: #variable:of:changedTo:]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
monitoredInstVars: anObject

monitoredInstVars := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
monitoredInstVars

^ monitoredInstVars ifNil: [monitoredInstVars := Dictionary new]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
change detection
uninstallMonitors

self unmonitorInstVars: self monitoredInstVars.
self monitoredInstVars: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
change detection
unmonitorInstVars: objectInstVarsDict

objectInstVarsDict keysAndValuesDo: [:object :instVars |
instVars do: [:instVar |
object unsubscribe: self fromAssignmentNotificationsFor: instVar]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
change detection
updateMonitors

self uninstallMonitors.
self installMonitors
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
change detection
variable: variableName of: aMonitoredObject changedTo: newValue

self updateMonitors.
self update
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@
"callbacksEnabled:" : "sl 12/26/2017 21:06",
"classesNotToMonitor" : "sl 1/12/2018 00:13",
"currentValue" : "sl 12/26/2017 20:23",
"disable" : "sl 1/10/2018 19:59",
"disable" : "sl 1/17/2018 18:46",
"disableAllCallbacks" : "sl 1/10/2018 19:53",
"enable" : "sl 1/17/2018 18:52",
"enableAllCallbacks" : "sl 1/10/2018 19:57",
"initialize" : "sl 12/26/2017 10:48",
"initialize" : "sl 1/17/2018 17:42",
"instVarOperations" : "sl 1/13/2018 00:26",
"instVarsToMonitor" : "sl 1/13/2018 00:26",
"installMonitors" : "sl 1/17/2018 18:50",
"invokeCallback:oldValue:newValue:" : "sl 12/26/2017 21:13",
"lastValue" : "sl 12/26/2017 18:49",
"monitorInstVars" : "sl 1/11/2018 00:25",
"monitorInstVars:" : "sl 1/17/2018 18:45",
"monitoredBlock" : "sl 12/23/2017 10:14",
"monitoredInstVars" : "sl 1/17/2018 18:47",
"monitoredInstVars:" : "sl 1/17/2018 18:35",
"onChangeDo:" : "sl 1/10/2018 19:50",
"printOn:" : "sl 12/26/2017 10:04",
"propagateChangeFrom:to:" : "sl 12/26/2017 21:13",
"removeAllCallbacks" : "sl 1/10/2018 19:52",
"removeCallback:" : "sl 1/10/2018 19:51",
"setLastValue:" : "sl 12/26/2017 18:43",
"setMonitoredBlock:" : "sl 12/26/2017 09:53",
"update" : "sl 12/26/2017 21:11" } }
"uninstallMonitors" : "sl 1/17/2018 18:42",
"unmonitorInstVars:" : "sl 1/17/2018 18:42",
"update" : "sl 12/26/2017 21:11",
"updateMonitors" : "sl 1/17/2018 18:39",
"variable:of:changedTo:" : "sl 1/17/2018 17:17" } }
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"monitoredBlock",
"callbacks",
"lastValue",
"callbacksEnabled" ],
"callbacksEnabled",
"monitoredInstVars" ],
"name" : "ActiveExpression",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
running
setUp

publisher := AExpMockPublisher new.
publisher := AExpMockPublisher new.
lastValue := 100.
value := self newValue.
callbackCount := 0.
callback := [callbackCount := callbackCount + 1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests
testAutomaticChangePropagation

activeExpression := ActiveExpression monitoring: [publisher variableOfInterest].
activeExpression onChangeDo: callback.
publisher variableOfInterest: self newValue.
self assert: 1 equals: callbackCount
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - simulation
testInstVarsInMethodsWithKeywordMessagesAreFound

| foundVars |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - simulation
testInstVarsInQuickMethodsAreFound

| foundVars |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
},
"instance" : {
"expectedFindings" : "sl 1/13/2018 00:05",
"setUp" : "sl 1/10/2018 20:09",
"setUp" : "sl 1/17/2018 17:00",
"testAutomaticChangePropagation" : "sl 1/17/2018 18:51",
"testInstVarsInMethodsWithKeywordMessagesAreFound" : "sl 1/13/2018 00:22",
"testInstVarsInQuickMethodsAreFound" : "sl 1/12/2018 23:03" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
],
"commentStamp" : "",
"instvars" : [
"activeExpression",
"callback",
"expression",
"publisher" ],
"name" : "ActiveExpressionChangeDetectionTests",
"pools" : [
],
"super" : "TestCase",
"super" : "ActiveExpressionTests",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
running
tearDown

activeExpression disable
activeExpression ifNotNil: [activeExpression disable].
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"newValue" : "sl 1/12/2018 10:18",
"previousValue" : "sl 1/12/2018 10:22",
"setUp" : "sl 1/12/2018 10:18",
"tearDown" : "sl 1/10/2018 19:58",
"tearDown" : "sl 1/17/2018 16:56",
"testCallbackInvocationWhenValueIdentityHasChanged" : "sl 1/12/2018 10:20",
"testCallbackInvocationWith1Argument" : "sl 1/12/2018 10:21",
"testCallbackInvocationWith2Arguments" : "sl 1/12/2018 10:23",
Expand Down

0 comments on commit ffbed60

Please sign in to comment.