Trapped-Demo.deploy.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. smalltalk.addPackage('Trapped-Demo', {});
  2. smalltalk.addClass('AppView', smalltalk.Widget, [], 'Trapped-Demo');
  3. smalltalk.addMethod(
  4. "_renderOn_",
  5. smalltalk.method({
  6. selector: "renderOn:",
  7. fn: function (html){
  8. var self=this;
  9. smalltalk.send(smalltalk.send(html,"_h2",[]),"_trapShow_",[["title"]]);
  10. smalltalk.send(smalltalk.send(html,"_p",[]),"_trapShow_",[["items"]]);
  11. return self}
  12. }),
  13. smalltalk.AppView);
  14. smalltalk.addClass('TrappedDumbDispatcher', smalltalk.TrappedDispatcher, ['queue'], 'Trapped-Demo');
  15. smalltalk.addMethod(
  16. "_add_",
  17. smalltalk.method({
  18. selector: "add:",
  19. fn: function (aTriplet){
  20. var self=this;
  21. smalltalk.send(self["@queue"],"_add_",[aTriplet]);
  22. smalltalk.send(self,"_dirty_",[smalltalk.send(aTriplet,"_first",[])]);
  23. return self}
  24. }),
  25. smalltalk.TrappedDumbDispatcher);
  26. smalltalk.addMethod(
  27. "_do_",
  28. smalltalk.method({
  29. selector: "do:",
  30. fn: function (aBlock){
  31. var self=this;
  32. smalltalk.send(self["@queue"],"_do_",[aBlock]);
  33. return self}
  34. }),
  35. smalltalk.TrappedDumbDispatcher);
  36. smalltalk.addMethod(
  37. "_initialize",
  38. smalltalk.method({
  39. selector: "initialize",
  40. fn: function (){
  41. var self=this;
  42. self["@queue"]=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
  43. return self}
  44. }),
  45. smalltalk.TrappedDumbDispatcher);
  46. smalltalk.addClass('TrappedPlainModel', smalltalk.TrappedModelWrapper, [], 'Trapped-Demo');
  47. smalltalk.addMethod(
  48. "_initialize",
  49. smalltalk.method({
  50. selector: "initialize",
  51. fn: function (){
  52. var self=this;
  53. smalltalk.send(self,"_initialize",[],smalltalk.TrappedModelWrapper);
  54. smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
  55. return self}
  56. }),
  57. smalltalk.TrappedPlainModel);
  58. smalltalk.addMethod(
  59. "_read_do_",
  60. smalltalk.method({
  61. selector: "read:do:",
  62. fn: function (path,aBlock){
  63. var self=this;
  64. var data;
  65. data=smalltalk.send(path,"_inject_into_",[smalltalk.send(self,"_payload",[]),(function(soFar,segment){
  66. return smalltalk.send(soFar,"_at_",[segment]);
  67. })]);
  68. smalltalk.send(aBlock,"_value_",[data]);
  69. return self}
  70. }),
  71. smalltalk.TrappedPlainModel);
  72. smalltalk.addMethod(
  73. "_start",
  74. smalltalk.method({
  75. selector: "start",
  76. fn: function (){
  77. var self=this;
  78. smalltalk.send(smalltalk.send(self,"_new",[]),"_start",[]);
  79. return self}
  80. }),
  81. smalltalk.TrappedPlainModel.klass);
  82. smalltalk.addClass('App', smalltalk.TrappedPlainModel, [], 'Trapped-Demo');
  83. smalltalk.addMethod(
  84. "_initialize",
  85. smalltalk.method({
  86. selector: "initialize",
  87. fn: function (){
  88. var self=this;
  89. smalltalk.send(self,"_initialize",[],smalltalk.TrappedPlainModel);
  90. smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("items","__minus_gt",[["hello", "world"]]),smalltalk.send("title","__minus_gt",["To-Do List"])])]);
  91. return self}
  92. }),
  93. smalltalk.App);