Kernel-Announcements.deploy.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. smalltalk.addPackage('Kernel-Announcements', {});
  2. smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['block', 'announcementClass'], 'Kernel-Announcements');
  3. smalltalk.addMethod(
  4. "_announcementClass",
  5. smalltalk.method({
  6. selector: "announcementClass",
  7. fn: function (){
  8. var self=this;
  9. return self["@announcementClass"];
  10. }
  11. }),
  12. smalltalk.AnnouncementSubscription);
  13. smalltalk.addMethod(
  14. "_announcementClass_",
  15. smalltalk.method({
  16. selector: "announcementClass:",
  17. fn: function (aClass){
  18. var self=this;
  19. self["@announcementClass"]=aClass;
  20. return self}
  21. }),
  22. smalltalk.AnnouncementSubscription);
  23. smalltalk.addMethod(
  24. "_block",
  25. smalltalk.method({
  26. selector: "block",
  27. fn: function (){
  28. var self=this;
  29. return self["@block"];
  30. }
  31. }),
  32. smalltalk.AnnouncementSubscription);
  33. smalltalk.addMethod(
  34. "_block_",
  35. smalltalk.method({
  36. selector: "block:",
  37. fn: function (aBlock){
  38. var self=this;
  39. self["@block"]=aBlock;
  40. return self}
  41. }),
  42. smalltalk.AnnouncementSubscription);
  43. smalltalk.addMethod(
  44. "_deliver_",
  45. smalltalk.method({
  46. selector: "deliver:",
  47. fn: function (anAnnouncement){
  48. var self=this;
  49. var $1;
  50. $1=smalltalk.send(self,"_handlesAnnouncement_",[anAnnouncement]);
  51. if(smalltalk.assert($1)){
  52. smalltalk.send(smalltalk.send(self,"_block",[]),"_value_",[anAnnouncement]);
  53. };
  54. return self}
  55. }),
  56. smalltalk.AnnouncementSubscription);
  57. smalltalk.addMethod(
  58. "_handlesAnnouncement_",
  59. smalltalk.method({
  60. selector: "handlesAnnouncement:",
  61. fn: function (anAnnouncement){
  62. var self=this;
  63. var $1;
  64. $1=smalltalk.send(anAnnouncement,"_isKindOf_",[smalltalk.send(self,"_announcementClass",[])]);
  65. return $1;
  66. }
  67. }),
  68. smalltalk.AnnouncementSubscription);
  69. smalltalk.addClass('Announcer', smalltalk.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
  70. smalltalk.addMethod(
  71. "_announce_",
  72. smalltalk.method({
  73. selector: "announce:",
  74. fn: function (anAnnouncement){
  75. var self=this;
  76. smalltalk.send(self["@subscriptions"],"_do_",[(function(each){
  77. return smalltalk.send(each,"_deliver_",[anAnnouncement]);
  78. })]);
  79. return self}
  80. }),
  81. smalltalk.Announcer);
  82. smalltalk.addMethod(
  83. "_initialize",
  84. smalltalk.method({
  85. selector: "initialize",
  86. fn: function (){
  87. var self=this;
  88. smalltalk.send(self,"_initialize",[],smalltalk.Object);
  89. self["@subscriptions"]=smalltalk.send((smalltalk.Array || Array),"_new",[]);
  90. return self}
  91. }),
  92. smalltalk.Announcer);
  93. smalltalk.addMethod(
  94. "_on_do_",
  95. smalltalk.method({
  96. selector: "on:do:",
  97. fn: function (aClass,aBlock){
  98. var self=this;
  99. var $1,$2;
  100. $1=smalltalk.send((smalltalk.AnnouncementSubscription || AnnouncementSubscription),"_new",[]);
  101. smalltalk.send($1,"_block_",[aBlock]);
  102. smalltalk.send($1,"_announcementClass_",[aClass]);
  103. $2=smalltalk.send($1,"_yourself",[]);
  104. smalltalk.send(self["@subscriptions"],"_add_",[$2]);
  105. return self}
  106. }),
  107. smalltalk.Announcer);