2
0

Kernel-Announcements.deploy.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. return self;}
  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. return self;}
  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. ((($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]);})]));
  50. return self;}
  51. }),
  52. smalltalk.AnnouncementSubscription);
  53. smalltalk.addMethod(
  54. "_handlesAnnouncement_",
  55. smalltalk.method({
  56. selector: "handlesAnnouncement:",
  57. fn: function (anAnnouncement){
  58. var self=this;
  59. return smalltalk.send(anAnnouncement, "_isKindOf_", [smalltalk.send(self, "_announcementClass", [])]);
  60. return self;}
  61. }),
  62. smalltalk.AnnouncementSubscription);
  63. smalltalk.addClass('Announcer', smalltalk.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
  64. smalltalk.addMethod(
  65. "_announce_",
  66. smalltalk.method({
  67. selector: "announce:",
  68. fn: function (anAnnouncement){
  69. var self=this;
  70. smalltalk.send(self['@subscriptions'], "_do_", [(function(each){return smalltalk.send(each, "_deliver_", [anAnnouncement]);})]);
  71. return self;}
  72. }),
  73. smalltalk.Announcer);
  74. smalltalk.addMethod(
  75. "_initialize",
  76. smalltalk.method({
  77. selector: "initialize",
  78. fn: function (){
  79. var self=this;
  80. smalltalk.send(self, "_initialize", [], smalltalk.Announcer.superclass || nil);
  81. (self['@subscriptions']=smalltalk.send((smalltalk.Array || Array), "_new", []));
  82. return self;}
  83. }),
  84. smalltalk.Announcer);
  85. smalltalk.addMethod(
  86. "_on_do_",
  87. smalltalk.method({
  88. selector: "on:do:",
  89. fn: function (aClass, aBlock){
  90. var self=this;
  91. 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", []))]);
  92. return self;}
  93. }),
  94. smalltalk.Announcer);