[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 
example[spec] Modify the listener of a MobileCoordinator
" self is a MobileThreadAction instance "
| jsObject js coordinatorSpec spec coordinatorConf listenersSpec newHandlerBlock |
newHandlerBlock := [:coordinator | self print: 'OK'].
jsObject := self basicAt: #spec.
js := JS @ jsObject.
coordinatorSpec := js @ #coordinator.
coordinatorConf := JS @ coordinatorSpec @ #configuration.
listenersSpec := JS @ coordinatorConf @ #listeners. 
" change property "
JS @ listenersSpec handleAt: #built: put: newHandlerBlock json.
" update rendered UI "
self update.
"refresh template"
self coordinator template listeners: JS @ listenersSpec.
"re-subscribe"
self coordinator 
	when: (JS @ listenersSpec) keys first 
	do: JS @ listenersSpec @ (JS @ listenersSpec) keys first.
" trigger event to test "
self coordinator triggerEvent: #built: withArguments: (Array with: self coordinator).