Trapped-Demo.st 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Smalltalk current createPackage: 'Trapped-Demo' properties: #{}!
  2. Widget subclass: #AppView
  3. instanceVariableNames: ''
  4. package: 'Trapped-Demo'!
  5. !AppView methodsFor: 'rendering'!
  6. renderOn: html
  7. html h2 trapShow: #('title').
  8. html p trapShow: #('items')
  9. ! !
  10. TrappedDispatcher subclass: #TrappedDumbDispatcher
  11. instanceVariableNames: 'queue'
  12. package: 'Trapped-Demo'!
  13. !TrappedDumbDispatcher methodsFor: 'accessing'!
  14. add: aTriplet
  15. queue add: aTriplet.
  16. self dirty: aTriplet first
  17. ! !
  18. !TrappedDumbDispatcher methodsFor: 'enumeration'!
  19. do: aBlock
  20. queue do: aBlock
  21. ! !
  22. !TrappedDumbDispatcher methodsFor: 'initialization'!
  23. initialize
  24. queue := OrderedCollection new
  25. ! !
  26. TrappedModelWrapper subclass: #TrappedPlainModel
  27. instanceVariableNames: ''
  28. package: 'Trapped-Demo'!
  29. !TrappedPlainModel methodsFor: 'action'!
  30. read: path do: aBlock
  31. | data |
  32. data := path inject: self payload
  33. into: [ :soFar :segment | soFar at: segment ].
  34. aBlock value: data.
  35. ! !
  36. !TrappedPlainModel methodsFor: 'initialization'!
  37. initialize
  38. super initialize.
  39. self dispatcher: TrappedDumbDispatcher new
  40. ! !
  41. !TrappedPlainModel class methodsFor: 'action'!
  42. start
  43. self new start
  44. ! !
  45. TrappedPlainModel subclass: #App
  46. instanceVariableNames: ''
  47. package: 'Trapped-Demo'!
  48. !App methodsFor: 'initialization'!
  49. initialize
  50. super initialize.
  51. self payload: #{'items'->#('hello' 'world'). 'title' -> 'To-Do List'}
  52. ! !