Axxord-Axon.js 23 KB

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