1
0

Kernel-Announcements.deploy.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. smalltalk.addPackage('Kernel-Announcements', {});
  2. smalltalk.addClass('Announcer', smalltalk.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
  3. smalltalk.addMethod(
  4. '_initialize',
  5. smalltalk.method({
  6. selector: 'initialize',
  7. fn: function (){
  8. var self=this;
  9. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  10. self['@subscriptions']=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection), "_new", []);
  11. return self;}
  12. }),
  13. smalltalk.Announcer);
  14. smalltalk.addMethod(
  15. '_on_do_',
  16. smalltalk.method({
  17. selector: 'on:do:',
  18. fn: function (aClass, aBlock){
  19. var self=this;
  20. 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", []))]);
  21. return self;}
  22. }),
  23. smalltalk.Announcer);
  24. smalltalk.addMethod(
  25. '_announce_',
  26. smalltalk.method({
  27. selector: 'announce:',
  28. fn: function (anAnnouncement){
  29. var self=this;
  30. smalltalk.send(self['@subscriptions'], "_do_", [(function(each){return smalltalk.send(each, "_deliver_", [anAnnouncement]);})]);
  31. return self;}
  32. }),
  33. smalltalk.Announcer);
  34. smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['block', 'announcementClass'], 'Kernel-Announcements');
  35. smalltalk.addMethod(
  36. '_announcementClass',
  37. smalltalk.method({
  38. selector: 'announcementClass',
  39. fn: function (){
  40. var self=this;
  41. return self['@announcementClass'];
  42. return self;}
  43. }),
  44. smalltalk.AnnouncementSubscription);
  45. smalltalk.addMethod(
  46. '_announcementClass_',
  47. smalltalk.method({
  48. selector: 'announcementClass:',
  49. fn: function (aClass){
  50. var self=this;
  51. self['@announcementClass']=aClass;
  52. return self;}
  53. }),
  54. smalltalk.AnnouncementSubscription);
  55. smalltalk.addMethod(
  56. '_block',
  57. smalltalk.method({
  58. selector: 'block',
  59. fn: function (){
  60. var self=this;
  61. return self['@block'];
  62. return self;}
  63. }),
  64. smalltalk.AnnouncementSubscription);
  65. smalltalk.addMethod(
  66. '_block_',
  67. smalltalk.method({
  68. selector: 'block:',
  69. fn: function (aBlock){
  70. var self=this;
  71. self['@block']=aBlock;
  72. return self;}
  73. }),
  74. smalltalk.AnnouncementSubscription);
  75. smalltalk.addMethod(
  76. '_deliver_',
  77. smalltalk.method({
  78. selector: 'deliver:',
  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. '_handlesAnnouncement_',
  87. smalltalk.method({
  88. selector: 'handlesAnnouncement:',
  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);