Axxord-Axon.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. define(["amber/boot", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  3. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  4. $core.addPackage("Axxord-Axon");
  5. ($core.packageDescriptors||$core.packages)["Axxord-Axon"].innerEval = function (expr) { return eval(expr); };
  6. ($core.packageDescriptors||$core.packages)["Axxord-Axon"].transport = {"type":"amd","amdNamespace":"axxord"};
  7. $core.addClass("Axon", $globals.Object, ["factory"], "Axxord-Axon");
  8. //>>excludeStart("ide", pragmas.excludeIdeData);
  9. $globals.Axon.comment="I represent a pub-sub based on a key (called 'aspect').\x0aI manage aspect-block subscriptions (called 'interests') as well as run blocks of dirtied interests.\x0aThe interest objects are responsible of decision if the change of an aspect is relevant for them.\x0aInterest object must be subclasses of `AxonInterest`.\x0a\x0aMy subclasses must provide implementation for:\x0a\x0a - add:\x0a - do:\x0a - clean";
  10. //>>excludeEnd("ide");
  11. $core.addMethod(
  12. $core.method({
  13. selector: "add:",
  14. protocol: "primitive ops",
  15. fn: function (anInterest){
  16. var self=this,$self=this;
  17. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  18. return $core.withContext(function($ctx1) {
  19. //>>excludeEnd("ctx");
  20. $self._subclassResponsibility();
  21. return self;
  22. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  23. }, function($ctx1) {$ctx1.fill(self,"add:",{anInterest:anInterest},$globals.Axon)});
  24. //>>excludeEnd("ctx");
  25. },
  26. //>>excludeStart("ide", pragmas.excludeIdeData);
  27. args: ["anInterest"],
  28. source: "add: anInterest\x0a\x09self subclassResponsibility",
  29. referencedClasses: [],
  30. //>>excludeEnd("ide");
  31. messageSends: ["subclassResponsibility"]
  32. }),
  33. $globals.Axon);
  34. $core.addMethod(
  35. $core.method({
  36. selector: "addInterest:",
  37. protocol: "accessing",
  38. fn: function (anInterest){
  39. var self=this,$self=this;
  40. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  41. return $core.withContext(function($ctx1) {
  42. //>>excludeEnd("ctx");
  43. var $1;
  44. $recv(anInterest)._flag();
  45. $1=$recv(anInterest)._yourself();
  46. $self._add_($1);
  47. $self._dirty_(true);
  48. return self;
  49. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  50. }, function($ctx1) {$ctx1.fill(self,"addInterest:",{anInterest:anInterest},$globals.Axon)});
  51. //>>excludeEnd("ctx");
  52. },
  53. //>>excludeStart("ide", pragmas.excludeIdeData);
  54. args: ["anInterest"],
  55. source: "addInterest: anInterest\x0a\x09self\x0a\x09\x09add: (anInterest flag; yourself);\x0a\x09\x09dirty: true",
  56. referencedClasses: [],
  57. //>>excludeEnd("ide");
  58. messageSends: ["add:", "flag", "yourself", "dirty:"]
  59. }),
  60. $globals.Axon);
  61. $core.addMethod(
  62. $core.method({
  63. selector: "changed:",
  64. protocol: "change-update",
  65. fn: function (anAspect){
  66. var self=this,$self=this;
  67. var needsToRun;
  68. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  69. return $core.withContext(function($ctx1) {
  70. //>>excludeEnd("ctx");
  71. var $1;
  72. needsToRun=false;
  73. $self._do_((function(each){
  74. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  75. return $core.withContext(function($ctx2) {
  76. //>>excludeEnd("ctx");
  77. $1=$recv(each)._accepts_(anAspect);
  78. if($core.assert($1)){
  79. $recv(each)._flag();
  80. needsToRun=true;
  81. return needsToRun;
  82. }
  83. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  84. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  85. //>>excludeEnd("ctx");
  86. }));
  87. $self._dirty_(needsToRun);
  88. return self;
  89. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  90. }, function($ctx1) {$ctx1.fill(self,"changed:",{anAspect:anAspect,needsToRun:needsToRun},$globals.Axon)});
  91. //>>excludeEnd("ctx");
  92. },
  93. //>>excludeStart("ide", pragmas.excludeIdeData);
  94. args: ["anAspect"],
  95. source: "changed: anAspect\x0a\x09| needsToRun |\x0a\x09needsToRun := false.\x0a\x09self do: [ :each |\x0a\x09\x09(each accepts: anAspect) ifTrue: [\x0a\x09\x09\x09each flag.\x0a\x09\x09\x09needsToRun := true ]].\x0a\x09self dirty: needsToRun",
  96. referencedClasses: [],
  97. //>>excludeEnd("ide");
  98. messageSends: ["do:", "ifTrue:", "accepts:", "flag", "dirty:"]
  99. }),
  100. $globals.Axon);
  101. $core.addMethod(
  102. $core.method({
  103. selector: "changedAll",
  104. protocol: "change-update",
  105. fn: function (){
  106. var self=this,$self=this;
  107. var needsToRun;
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. return $core.withContext(function($ctx1) {
  110. //>>excludeEnd("ctx");
  111. needsToRun=false;
  112. $self._do_((function(each){
  113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  114. return $core.withContext(function($ctx2) {
  115. //>>excludeEnd("ctx");
  116. $recv(each)._flag();
  117. needsToRun=true;
  118. return needsToRun;
  119. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  120. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  121. //>>excludeEnd("ctx");
  122. }));
  123. $self._dirty_(needsToRun);
  124. return self;
  125. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  126. }, function($ctx1) {$ctx1.fill(self,"changedAll",{needsToRun:needsToRun},$globals.Axon)});
  127. //>>excludeEnd("ctx");
  128. },
  129. //>>excludeStart("ide", pragmas.excludeIdeData);
  130. args: [],
  131. source: "changedAll\x0a\x09| needsToRun |\x0a\x09needsToRun := false.\x0a\x09self do: [ :each |\x0a\x09\x09each flag.\x0a\x09\x09needsToRun := true ].\x0a\x09self dirty: needsToRun",
  132. referencedClasses: [],
  133. //>>excludeEnd("ide");
  134. messageSends: ["do:", "flag", "dirty:"]
  135. }),
  136. $globals.Axon);
  137. $core.addMethod(
  138. $core.method({
  139. selector: "clean",
  140. protocol: "primitive ops",
  141. fn: function (){
  142. var self=this,$self=this;
  143. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  144. return $core.withContext(function($ctx1) {
  145. //>>excludeEnd("ctx");
  146. $self._subclassResponsibility();
  147. return self;
  148. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  149. }, function($ctx1) {$ctx1.fill(self,"clean",{},$globals.Axon)});
  150. //>>excludeEnd("ctx");
  151. },
  152. //>>excludeStart("ide", pragmas.excludeIdeData);
  153. args: [],
  154. source: "clean\x0a\x09self subclassResponsibility",
  155. referencedClasses: [],
  156. //>>excludeEnd("ide");
  157. messageSends: ["subclassResponsibility"]
  158. }),
  159. $globals.Axon);
  160. $core.addMethod(
  161. $core.method({
  162. selector: "dirty:",
  163. protocol: "private",
  164. fn: function (aBoolean){
  165. var self=this,$self=this;
  166. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  167. return $core.withContext(function($ctx1) {
  168. //>>excludeEnd("ctx");
  169. if($core.assert(aBoolean)){
  170. $recv((function(){
  171. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  172. return $core.withContext(function($ctx2) {
  173. //>>excludeEnd("ctx");
  174. return $self._run();
  175. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  176. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  177. //>>excludeEnd("ctx");
  178. }))._fork();
  179. }
  180. return self;
  181. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  182. }, function($ctx1) {$ctx1.fill(self,"dirty:",{aBoolean:aBoolean},$globals.Axon)});
  183. //>>excludeEnd("ctx");
  184. },
  185. //>>excludeStart("ide", pragmas.excludeIdeData);
  186. args: ["aBoolean"],
  187. source: "dirty: aBoolean\x0a\x09aBoolean ifTrue: [[ self run ] fork]",
  188. referencedClasses: [],
  189. //>>excludeEnd("ide");
  190. messageSends: ["ifTrue:", "fork", "run"]
  191. }),
  192. $globals.Axon);
  193. $core.addMethod(
  194. $core.method({
  195. selector: "do:",
  196. protocol: "primitive ops",
  197. fn: function (aBlock){
  198. var self=this,$self=this;
  199. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  200. return $core.withContext(function($ctx1) {
  201. //>>excludeEnd("ctx");
  202. $self._subclassResponsibility();
  203. return self;
  204. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  205. }, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},$globals.Axon)});
  206. //>>excludeEnd("ctx");
  207. },
  208. //>>excludeStart("ide", pragmas.excludeIdeData);
  209. args: ["aBlock"],
  210. source: "do: aBlock\x0a\x09self subclassResponsibility",
  211. referencedClasses: [],
  212. //>>excludeEnd("ide");
  213. messageSends: ["subclassResponsibility"]
  214. }),
  215. $globals.Axon);
  216. $core.addMethod(
  217. $core.method({
  218. selector: "run",
  219. protocol: "private",
  220. fn: function (){
  221. var self=this,$self=this;
  222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  223. return $core.withContext(function($ctx1) {
  224. //>>excludeEnd("ctx");
  225. var $1,$2,$3;
  226. $recv((function(){
  227. var needsClean;
  228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  229. return $core.withContext(function($ctx2) {
  230. //>>excludeEnd("ctx");
  231. needsClean=false;
  232. needsClean;
  233. $self._do_((function(each){
  234. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  235. return $core.withContext(function($ctx3) {
  236. //>>excludeEnd("ctx");
  237. $1=$recv(each)._isFlagged();
  238. if($core.assert($1)){
  239. $recv(each)._run();
  240. }
  241. $2=$recv(each)._isClosed();
  242. if($core.assert($2)){
  243. needsClean=true;
  244. return needsClean;
  245. }
  246. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  247. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)});
  248. //>>excludeEnd("ctx");
  249. }));
  250. $3=needsClean;
  251. if($core.assert($3)){
  252. return $self._clean();
  253. }
  254. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  255. }, function($ctx2) {$ctx2.fillBlock({needsClean:needsClean},$ctx1,1)});
  256. //>>excludeEnd("ctx");
  257. }))._on_do_($globals.Error,(function(){
  258. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  259. return $core.withContext(function($ctx2) {
  260. //>>excludeEnd("ctx");
  261. return $self._dirty_(true);
  262. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  263. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)});
  264. //>>excludeEnd("ctx");
  265. }));
  266. return self;
  267. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  268. }, function($ctx1) {$ctx1.fill(self,"run",{},$globals.Axon)});
  269. //>>excludeEnd("ctx");
  270. },
  271. //>>excludeStart("ide", pragmas.excludeIdeData);
  272. args: [],
  273. source: "run\x0a\x09[\x0a\x09\x09| needsClean |\x0a\x09 needsClean := false.\x0a\x09\x09self do: [ :each |\x0a\x09\x09\x09each isFlagged ifTrue: [ each run ].\x0a\x09 each isClosed ifTrue: [ needsClean := true ]\x0a\x09\x09].\x0a \x09needsClean ifTrue: [ self clean ]\x0a\x09] on: Error do: [ self dirty: true ]",
  274. referencedClasses: ["Error"],
  275. //>>excludeEnd("ide");
  276. messageSends: ["on:do:", "do:", "ifTrue:", "isFlagged", "run", "isClosed", "clean", "dirty:"]
  277. }),
  278. $globals.Axon);
  279. $core.addClass("SimpleAxon", $globals.Axon, ["queue"], "Axxord-Axon");
  280. $core.addMethod(
  281. $core.method({
  282. selector: "add:",
  283. protocol: "primitive ops",
  284. fn: function (aSubscription){
  285. var self=this,$self=this;
  286. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  287. return $core.withContext(function($ctx1) {
  288. //>>excludeEnd("ctx");
  289. $recv($self["@queue"])._add_(aSubscription);
  290. return self;
  291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  292. }, function($ctx1) {$ctx1.fill(self,"add:",{aSubscription:aSubscription},$globals.SimpleAxon)});
  293. //>>excludeEnd("ctx");
  294. },
  295. //>>excludeStart("ide", pragmas.excludeIdeData);
  296. args: ["aSubscription"],
  297. source: "add: aSubscription\x0a\x09queue add: aSubscription.",
  298. referencedClasses: [],
  299. //>>excludeEnd("ide");
  300. messageSends: ["add:"]
  301. }),
  302. $globals.SimpleAxon);
  303. $core.addMethod(
  304. $core.method({
  305. selector: "clean",
  306. protocol: "primitive ops",
  307. fn: function (){
  308. var self=this,$self=this;
  309. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  310. return $core.withContext(function($ctx1) {
  311. //>>excludeEnd("ctx");
  312. $self["@queue"]=$recv($self["@queue"])._reject_((function(each){
  313. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  314. return $core.withContext(function($ctx2) {
  315. //>>excludeEnd("ctx");
  316. return $recv(each)._isClosed();
  317. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  318. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  319. //>>excludeEnd("ctx");
  320. }));
  321. return self;
  322. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  323. }, function($ctx1) {$ctx1.fill(self,"clean",{},$globals.SimpleAxon)});
  324. //>>excludeEnd("ctx");
  325. },
  326. //>>excludeStart("ide", pragmas.excludeIdeData);
  327. args: [],
  328. source: "clean\x0a\x09queue := queue reject: [ :each | each isClosed ]",
  329. referencedClasses: [],
  330. //>>excludeEnd("ide");
  331. messageSends: ["reject:", "isClosed"]
  332. }),
  333. $globals.SimpleAxon);
  334. $core.addMethod(
  335. $core.method({
  336. selector: "do:",
  337. protocol: "primitive ops",
  338. fn: function (aBlock){
  339. var self=this,$self=this;
  340. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  341. return $core.withContext(function($ctx1) {
  342. //>>excludeEnd("ctx");
  343. $recv($self["@queue"])._do_(aBlock);
  344. return self;
  345. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  346. }, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},$globals.SimpleAxon)});
  347. //>>excludeEnd("ctx");
  348. },
  349. //>>excludeStart("ide", pragmas.excludeIdeData);
  350. args: ["aBlock"],
  351. source: "do: aBlock\x0a\x09queue do: aBlock",
  352. referencedClasses: [],
  353. //>>excludeEnd("ide");
  354. messageSends: ["do:"]
  355. }),
  356. $globals.SimpleAxon);
  357. $core.addMethod(
  358. $core.method({
  359. selector: "initialize",
  360. protocol: "initialization",
  361. fn: function (){
  362. var self=this,$self=this;
  363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  364. return $core.withContext(function($ctx1) {
  365. //>>excludeEnd("ctx");
  366. (
  367. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  368. $ctx1.supercall = true,
  369. //>>excludeEnd("ctx");
  370. ($globals.SimpleAxon.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  371. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  372. $ctx1.supercall = false;
  373. //>>excludeEnd("ctx");;
  374. $self["@queue"]=$recv($globals.OrderedCollection)._new();
  375. return self;
  376. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  377. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.SimpleAxon)});
  378. //>>excludeEnd("ctx");
  379. },
  380. //>>excludeStart("ide", pragmas.excludeIdeData);
  381. args: [],
  382. source: "initialize\x0a super initialize.\x0a\x09queue := OrderedCollection new",
  383. referencedClasses: ["OrderedCollection"],
  384. //>>excludeEnd("ide");
  385. messageSends: ["initialize", "new"]
  386. }),
  387. $globals.SimpleAxon);
  388. $core.addClass("AxonInterest", $globals.Object, ["flagged"], "Axxord-Axon");
  389. $core.addMethod(
  390. $core.method({
  391. selector: "accepts:",
  392. protocol: "testing",
  393. fn: function (anAspect){
  394. var self=this,$self=this;
  395. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  396. return $core.withContext(function($ctx1) {
  397. //>>excludeEnd("ctx");
  398. $self._subclassResponsibility();
  399. return self;
  400. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  401. }, function($ctx1) {$ctx1.fill(self,"accepts:",{anAspect:anAspect},$globals.AxonInterest)});
  402. //>>excludeEnd("ctx");
  403. },
  404. //>>excludeStart("ide", pragmas.excludeIdeData);
  405. args: ["anAspect"],
  406. source: "accepts: anAspect\x0a \x22Should return true if change for anAspect is relevant for this AxonInterest\x22\x0a self subclassResponsibility",
  407. referencedClasses: [],
  408. //>>excludeEnd("ide");
  409. messageSends: ["subclassResponsibility"]
  410. }),
  411. $globals.AxonInterest);
  412. $core.addMethod(
  413. $core.method({
  414. selector: "close",
  415. protocol: "action",
  416. fn: function (){
  417. var self=this,$self=this;
  418. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  419. return $core.withContext(function($ctx1) {
  420. //>>excludeEnd("ctx");
  421. $self._subclassResponsibility();
  422. return self;
  423. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  424. }, function($ctx1) {$ctx1.fill(self,"close",{},$globals.AxonInterest)});
  425. //>>excludeEnd("ctx");
  426. },
  427. //>>excludeStart("ide", pragmas.excludeIdeData);
  428. args: [],
  429. source: "close\x0a\x09self subclassResponsibility",
  430. referencedClasses: [],
  431. //>>excludeEnd("ide");
  432. messageSends: ["subclassResponsibility"]
  433. }),
  434. $globals.AxonInterest);
  435. $core.addMethod(
  436. $core.method({
  437. selector: "enact",
  438. protocol: "action",
  439. fn: function (){
  440. var self=this,$self=this;
  441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  442. return $core.withContext(function($ctx1) {
  443. //>>excludeEnd("ctx");
  444. $self._subclassResponsibility();
  445. return self;
  446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  447. }, function($ctx1) {$ctx1.fill(self,"enact",{},$globals.AxonInterest)});
  448. //>>excludeEnd("ctx");
  449. },
  450. //>>excludeStart("ide", pragmas.excludeIdeData);
  451. args: [],
  452. source: "enact\x0a\x09self subclassResponsibility",
  453. referencedClasses: [],
  454. //>>excludeEnd("ide");
  455. messageSends: ["subclassResponsibility"]
  456. }),
  457. $globals.AxonInterest);
  458. $core.addMethod(
  459. $core.method({
  460. selector: "flag",
  461. protocol: "accessing",
  462. fn: function (){
  463. var self=this,$self=this;
  464. $self["@flagged"]=true;
  465. return self;
  466. },
  467. //>>excludeStart("ide", pragmas.excludeIdeData);
  468. args: [],
  469. source: "flag\x0a\x09flagged := true",
  470. referencedClasses: [],
  471. //>>excludeEnd("ide");
  472. messageSends: []
  473. }),
  474. $globals.AxonInterest);
  475. $core.addMethod(
  476. $core.method({
  477. selector: "initialize",
  478. protocol: "initialization",
  479. fn: function (){
  480. var self=this,$self=this;
  481. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  482. return $core.withContext(function($ctx1) {
  483. //>>excludeEnd("ctx");
  484. (
  485. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  486. $ctx1.supercall = true,
  487. //>>excludeEnd("ctx");
  488. ($globals.AxonInterest.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  490. $ctx1.supercall = false;
  491. //>>excludeEnd("ctx");;
  492. $self["@flagged"]=false;
  493. return self;
  494. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  495. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.AxonInterest)});
  496. //>>excludeEnd("ctx");
  497. },
  498. //>>excludeStart("ide", pragmas.excludeIdeData);
  499. args: [],
  500. source: "initialize\x0a\x09super initialize.\x0a flagged := false.",
  501. referencedClasses: [],
  502. //>>excludeEnd("ide");
  503. messageSends: ["initialize"]
  504. }),
  505. $globals.AxonInterest);
  506. $core.addMethod(
  507. $core.method({
  508. selector: "isClosed",
  509. protocol: "testing",
  510. fn: function (){
  511. var self=this,$self=this;
  512. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  513. return $core.withContext(function($ctx1) {
  514. //>>excludeEnd("ctx");
  515. $self._subclassResponsibility();
  516. return self;
  517. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  518. }, function($ctx1) {$ctx1.fill(self,"isClosed",{},$globals.AxonInterest)});
  519. //>>excludeEnd("ctx");
  520. },
  521. //>>excludeStart("ide", pragmas.excludeIdeData);
  522. args: [],
  523. source: "isClosed\x0a\x09self subclassResponsibility",
  524. referencedClasses: [],
  525. //>>excludeEnd("ide");
  526. messageSends: ["subclassResponsibility"]
  527. }),
  528. $globals.AxonInterest);
  529. $core.addMethod(
  530. $core.method({
  531. selector: "isFlagged",
  532. protocol: "testing",
  533. fn: function (){
  534. var self=this,$self=this;
  535. return $self["@flagged"];
  536. },
  537. //>>excludeStart("ide", pragmas.excludeIdeData);
  538. args: [],
  539. source: "isFlagged\x0a\x09^flagged",
  540. referencedClasses: [],
  541. //>>excludeEnd("ide");
  542. messageSends: []
  543. }),
  544. $globals.AxonInterest);
  545. $core.addMethod(
  546. $core.method({
  547. selector: "run",
  548. protocol: "action",
  549. fn: function (){
  550. var self=this,$self=this;
  551. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  552. return $core.withContext(function($ctx1) {
  553. //>>excludeEnd("ctx");
  554. $recv((function(){
  555. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  556. return $core.withContext(function($ctx2) {
  557. //>>excludeEnd("ctx");
  558. $self["@flagged"]=false;
  559. $self["@flagged"];
  560. return $self._enact();
  561. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  562. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  563. //>>excludeEnd("ctx");
  564. }))._on_do_($globals.AxonOff,(function(){
  565. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  566. return $core.withContext(function($ctx2) {
  567. //>>excludeEnd("ctx");
  568. return $self._close();
  569. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  570. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  571. //>>excludeEnd("ctx");
  572. }));
  573. return self;
  574. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  575. }, function($ctx1) {$ctx1.fill(self,"run",{},$globals.AxonInterest)});
  576. //>>excludeEnd("ctx");
  577. },
  578. //>>excludeStart("ide", pragmas.excludeIdeData);
  579. args: [],
  580. source: "run\x0a\x09[ flagged := false. self enact ]\x0a on: AxonOff do: [ self close ]",
  581. referencedClasses: ["AxonOff"],
  582. //>>excludeEnd("ide");
  583. messageSends: ["on:do:", "enact", "close"]
  584. }),
  585. $globals.AxonInterest);
  586. $core.addClass("PluggableInterest", $globals.AxonInterest, ["acceptBlock", "enactBlock"], "Axxord-Axon");
  587. $core.addMethod(
  588. $core.method({
  589. selector: "accept:enact:",
  590. protocol: "accessing",
  591. fn: function (aBlock,anotherBlock){
  592. var self=this,$self=this;
  593. $self["@acceptBlock"]=aBlock;
  594. $self["@enactBlock"]=anotherBlock;
  595. return self;
  596. },
  597. //>>excludeStart("ide", pragmas.excludeIdeData);
  598. args: ["aBlock", "anotherBlock"],
  599. source: "accept: aBlock enact: anotherBlock\x0a\x09acceptBlock := aBlock.\x0a enactBlock := anotherBlock",
  600. referencedClasses: [],
  601. //>>excludeEnd("ide");
  602. messageSends: []
  603. }),
  604. $globals.PluggableInterest);
  605. $core.addMethod(
  606. $core.method({
  607. selector: "accepts:",
  608. protocol: "testing",
  609. fn: function (anAspect){
  610. var self=this,$self=this;
  611. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  612. return $core.withContext(function($ctx1) {
  613. //>>excludeEnd("ctx");
  614. return $recv($self["@acceptBlock"])._value_(anAspect);
  615. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  616. }, function($ctx1) {$ctx1.fill(self,"accepts:",{anAspect:anAspect},$globals.PluggableInterest)});
  617. //>>excludeEnd("ctx");
  618. },
  619. //>>excludeStart("ide", pragmas.excludeIdeData);
  620. args: ["anAspect"],
  621. source: "accepts: anAspect\x0a ^ acceptBlock value: anAspect",
  622. referencedClasses: [],
  623. //>>excludeEnd("ide");
  624. messageSends: ["value:"]
  625. }),
  626. $globals.PluggableInterest);
  627. $core.addMethod(
  628. $core.method({
  629. selector: "close",
  630. protocol: "action",
  631. fn: function (){
  632. var self=this,$self=this;
  633. $self["@acceptBlock"]=nil;
  634. $self["@enactBlock"]=nil;
  635. return self;
  636. },
  637. //>>excludeStart("ide", pragmas.excludeIdeData);
  638. args: [],
  639. source: "close\x0a\x09acceptBlock := nil.\x0a\x09enactBlock := nil",
  640. referencedClasses: [],
  641. //>>excludeEnd("ide");
  642. messageSends: []
  643. }),
  644. $globals.PluggableInterest);
  645. $core.addMethod(
  646. $core.method({
  647. selector: "enact",
  648. protocol: "action",
  649. fn: function (){
  650. var self=this,$self=this;
  651. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  652. return $core.withContext(function($ctx1) {
  653. //>>excludeEnd("ctx");
  654. $recv($self["@enactBlock"])._value();
  655. return self;
  656. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  657. }, function($ctx1) {$ctx1.fill(self,"enact",{},$globals.PluggableInterest)});
  658. //>>excludeEnd("ctx");
  659. },
  660. //>>excludeStart("ide", pragmas.excludeIdeData);
  661. args: [],
  662. source: "enact\x0a\x09enactBlock value",
  663. referencedClasses: [],
  664. //>>excludeEnd("ide");
  665. messageSends: ["value"]
  666. }),
  667. $globals.PluggableInterest);
  668. $core.addMethod(
  669. $core.method({
  670. selector: "initialize",
  671. protocol: "initialization",
  672. fn: function (){
  673. var self=this,$self=this;
  674. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  675. return $core.withContext(function($ctx1) {
  676. //>>excludeEnd("ctx");
  677. (
  678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  679. $ctx1.supercall = true,
  680. //>>excludeEnd("ctx");
  681. ($globals.PluggableInterest.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  682. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  683. $ctx1.supercall = false;
  684. //>>excludeEnd("ctx");;
  685. $self._close();
  686. return self;
  687. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  688. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.PluggableInterest)});
  689. //>>excludeEnd("ctx");
  690. },
  691. //>>excludeStart("ide", pragmas.excludeIdeData);
  692. args: [],
  693. source: "initialize\x0a\x09super initialize.\x0a self close",
  694. referencedClasses: [],
  695. //>>excludeEnd("ide");
  696. messageSends: ["initialize", "close"]
  697. }),
  698. $globals.PluggableInterest);
  699. $core.addMethod(
  700. $core.method({
  701. selector: "isClosed",
  702. protocol: "testing",
  703. fn: function (){
  704. var self=this,$self=this;
  705. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  706. return $core.withContext(function($ctx1) {
  707. //>>excludeEnd("ctx");
  708. return $recv($self["@acceptBlock"])._isNil();
  709. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  710. }, function($ctx1) {$ctx1.fill(self,"isClosed",{},$globals.PluggableInterest)});
  711. //>>excludeEnd("ctx");
  712. },
  713. //>>excludeStart("ide", pragmas.excludeIdeData);
  714. args: [],
  715. source: "isClosed\x0a\x09^ acceptBlock isNil",
  716. referencedClasses: [],
  717. //>>excludeEnd("ide");
  718. messageSends: ["isNil"]
  719. }),
  720. $globals.PluggableInterest);
  721. $core.addClass("AxonOff", $globals.Error, [], "Axxord-Axon");
  722. //>>excludeStart("ide", pragmas.excludeIdeData);
  723. $globals.AxonOff.comment="Signal me from the subscription block to unsubscribe it.";
  724. //>>excludeEnd("ide");
  725. });