Kernel-Announcements.deploy.js 3.1 KB

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