Sedux.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. define("sedux/Sedux", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. $core.addPackage('Sedux');
  4. $core.packages["Sedux"].innerEval = function (expr) { return eval(expr); };
  5. $core.packages["Sedux"].transport = {"type":"amd","amdNamespace":"sedux"};
  6. $core.addClass('SeduxCreatorClass', $globals.Object, [], 'Sedux');
  7. $core.addMethod(
  8. $core.method({
  9. selector: "<<",
  10. protocol: 'as yet unclassified',
  11. fn: function (aStoreEnhancer){
  12. var self=this;
  13. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  14. return $core.withContext(function($ctx1) {
  15. //>>excludeEnd("ctx");
  16. return $recv(aStoreEnhancer)._next_(self);
  17. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  18. }, function($ctx1) {$ctx1.fill(self,"<<",{aStoreEnhancer:aStoreEnhancer},$globals.SeduxCreatorClass.klass)});
  19. //>>excludeEnd("ctx");
  20. },
  21. //>>excludeStart("ide", pragmas.excludeIdeData);
  22. args: ["aStoreEnhancer"],
  23. source: "<< aStoreEnhancer\x0a\x09^ aStoreEnhancer next: self",
  24. referencedClasses: [],
  25. //>>excludeEnd("ide");
  26. messageSends: ["next:"]
  27. }),
  28. $globals.SeduxCreatorClass.klass);
  29. $core.addMethod(
  30. $core.method({
  31. selector: "inject:",
  32. protocol: 'as yet unclassified',
  33. fn: function (anObject){
  34. var self=this;
  35. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  36. return $core.withContext(function($ctx1) {
  37. //>>excludeEnd("ctx");
  38. return self._inject_into_(anObject,nil);
  39. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  40. }, function($ctx1) {$ctx1.fill(self,"inject:",{anObject:anObject},$globals.SeduxCreatorClass.klass)});
  41. //>>excludeEnd("ctx");
  42. },
  43. //>>excludeStart("ide", pragmas.excludeIdeData);
  44. args: ["anObject"],
  45. source: "inject: anObject\x0a\x09^ self inject: anObject into: nil",
  46. referencedClasses: [],
  47. //>>excludeEnd("ide");
  48. messageSends: ["inject:into:"]
  49. }),
  50. $globals.SeduxCreatorClass.klass);
  51. $core.addClass('Sedux', $globals.SeduxCreatorClass, [], 'Sedux');
  52. $core.addMethod(
  53. $core.method({
  54. selector: "dispatch:with:fallback:",
  55. protocol: 'as yet unclassified',
  56. fn: function (anAction,aReceiver,aBlock){
  57. var self=this;
  58. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  59. return $core.withContext(function($ctx1) {
  60. //>>excludeEnd("ctx");
  61. var $1;
  62. $1=$recv(aReceiver)._respondsTo_($recv(anAction)._selector());
  63. return $recv($1)._ifTrue_ifFalse_((function(){
  64. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  65. return $core.withContext(function($ctx2) {
  66. //>>excludeEnd("ctx");
  67. return $recv(anAction)._sendTo_(aReceiver);
  68. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  69. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  70. //>>excludeEnd("ctx");
  71. }),aBlock);
  72. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  73. }, function($ctx1) {$ctx1.fill(self,"dispatch:with:fallback:",{anAction:anAction,aReceiver:aReceiver,aBlock:aBlock},$globals.Sedux.klass)});
  74. //>>excludeEnd("ctx");
  75. },
  76. //>>excludeStart("ide", pragmas.excludeIdeData);
  77. args: ["anAction", "aReceiver", "aBlock"],
  78. source: "dispatch: anAction with: aReceiver fallback: aBlock\x0a\x09^ (aReceiver respondsTo: anAction selector)\x0a\x09\x09ifTrue: [ anAction sendTo: aReceiver ]\x0a\x09\x09ifFalse: aBlock",
  79. referencedClasses: [],
  80. //>>excludeEnd("ide");
  81. messageSends: ["ifTrue:ifFalse:", "respondsTo:", "selector", "sendTo:"]
  82. }),
  83. $globals.Sedux.klass);
  84. $core.addMethod(
  85. $core.method({
  86. selector: "inject:into:",
  87. protocol: 'as yet unclassified',
  88. fn: function (aReducer,anObject){
  89. var self=this;
  90. return self;
  91. },
  92. //>>excludeStart("ide", pragmas.excludeIdeData);
  93. args: ["aReducer", "anObject"],
  94. source: "inject: aReducer into: anObject\x0a\x09\x22Creates a store, dispatches initiating message\x22",
  95. referencedClasses: [],
  96. //>>excludeEnd("ide");
  97. messageSends: []
  98. }),
  99. $globals.Sedux.klass);
  100. $core.addClass('SeduxDecorator', $globals.SeduxCreatorClass, ['next'], 'Sedux');
  101. $core.addMethod(
  102. $core.method({
  103. selector: "next:",
  104. protocol: 'accessing',
  105. fn: function (anObject){
  106. var self=this;
  107. self["@next"]=anObject;
  108. return self;
  109. },
  110. //>>excludeStart("ide", pragmas.excludeIdeData);
  111. args: ["anObject"],
  112. source: "next: anObject\x0a\x09next := anObject",
  113. referencedClasses: [],
  114. //>>excludeEnd("ide");
  115. messageSends: []
  116. }),
  117. $globals.SeduxDecorator);
  118. $globals.SeduxDecorator.klass.iVarNames = ['next'];
  119. $core.addMethod(
  120. $core.method({
  121. selector: "inject:into:",
  122. protocol: 'as yet unclassified',
  123. fn: function (aReducer,anObject){
  124. var self=this;
  125. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  126. return $core.withContext(function($ctx1) {
  127. //>>excludeEnd("ctx");
  128. return $recv($globals.SeduxDecoratedStore)._dispatch_next_(self._new(),self._nextInject_into_(aReducer,anObject));
  129. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  130. }, function($ctx1) {$ctx1.fill(self,"inject:into:",{aReducer:aReducer,anObject:anObject},$globals.SeduxDecorator.klass)});
  131. //>>excludeEnd("ctx");
  132. },
  133. //>>excludeStart("ide", pragmas.excludeIdeData);
  134. args: ["aReducer", "anObject"],
  135. source: "inject: aReducer into: anObject\x0a\x09^ SeduxDecoratedStore dispatch: self new next: (self nextInject: aReducer into: anObject)",
  136. referencedClasses: ["SeduxDecoratedStore"],
  137. //>>excludeEnd("ide");
  138. messageSends: ["dispatch:next:", "new", "nextInject:into:"]
  139. }),
  140. $globals.SeduxDecorator.klass);
  141. $core.addMethod(
  142. $core.method({
  143. selector: "next:",
  144. protocol: 'as yet unclassified',
  145. fn: function (aStoreCreator){
  146. var self=this;
  147. self["@next"]=aStoreCreator;
  148. return self;
  149. },
  150. //>>excludeStart("ide", pragmas.excludeIdeData);
  151. args: ["aStoreCreator"],
  152. source: "next: aStoreCreator\x0a\x09next := aStoreCreator.\x0a\x09^self",
  153. referencedClasses: [],
  154. //>>excludeEnd("ide");
  155. messageSends: []
  156. }),
  157. $globals.SeduxDecorator.klass);
  158. $core.addMethod(
  159. $core.method({
  160. selector: "nextInject:into:",
  161. protocol: 'as yet unclassified',
  162. fn: function (aReducer,anObject){
  163. var self=this;
  164. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  165. return $core.withContext(function($ctx1) {
  166. //>>excludeEnd("ctx");
  167. return $recv(self["@next"])._inject_into_(aReducer,anObject);
  168. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  169. }, function($ctx1) {$ctx1.fill(self,"nextInject:into:",{aReducer:aReducer,anObject:anObject},$globals.SeduxDecorator.klass)});
  170. //>>excludeEnd("ctx");
  171. },
  172. //>>excludeStart("ide", pragmas.excludeIdeData);
  173. args: ["aReducer", "anObject"],
  174. source: "nextInject: aReducer into: anObject\x0a\x09^ next inject: aReducer into: anObject",
  175. referencedClasses: [],
  176. //>>excludeEnd("ide");
  177. messageSends: ["inject:into:"]
  178. }),
  179. $globals.SeduxDecorator.klass);
  180. $core.addClass('SeduxFoo', $globals.SeduxDecorator, [], 'Sedux');
  181. $core.addClass('SeduxDecoratedStore', $globals.Object, ['next', 'dispatch'], 'Sedux');
  182. $core.addMethod(
  183. $core.method({
  184. selector: "dispatch:",
  185. protocol: 'accessing',
  186. fn: function (anAction){
  187. var self=this;
  188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  189. return $core.withContext(function($ctx1) {
  190. //>>excludeEnd("ctx");
  191. var $early={};
  192. try {
  193. return $recv($globals.Sedux)._dispatch_with_fallback_(anAction,self["@dispatch"],(function(){
  194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  195. return $core.withContext(function($ctx2) {
  196. //>>excludeEnd("ctx");
  197. throw $early=[$recv(self["@next"])._dispatch_(anAction)];
  198. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  199. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  200. //>>excludeEnd("ctx");
  201. }));
  202. }
  203. catch(e) {if(e===$early)return e[0]; throw e}
  204. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  205. }, function($ctx1) {$ctx1.fill(self,"dispatch:",{anAction:anAction},$globals.SeduxDecoratedStore)});
  206. //>>excludeEnd("ctx");
  207. },
  208. //>>excludeStart("ide", pragmas.excludeIdeData);
  209. args: ["anAction"],
  210. source: "dispatch: anAction\x0a\x09^ Sedux\x0a\x09\x09dispatch: anAction\x0a\x09\x09with: dispatch\x0a\x09\x09fallback: [ ^ next dispatch: anAction ]",
  211. referencedClasses: ["Sedux"],
  212. //>>excludeEnd("ide");
  213. messageSends: ["dispatch:with:fallback:", "dispatch:"]
  214. }),
  215. $globals.SeduxDecoratedStore);
  216. $core.addMethod(
  217. $core.method({
  218. selector: "dispatch:next:",
  219. protocol: 'accessing',
  220. fn: function (aDispatcher,aStore){
  221. var self=this;
  222. self["@dispatch"]=aDispatcher;
  223. self["@next"]=aStore;
  224. return self;
  225. },
  226. //>>excludeStart("ide", pragmas.excludeIdeData);
  227. args: ["aDispatcher", "aStore"],
  228. source: "dispatch: aDispatcher next: aStore\x0a\x09dispatch := aDispatcher.\x0a\x09next := aStore",
  229. referencedClasses: [],
  230. //>>excludeEnd("ide");
  231. messageSends: []
  232. }),
  233. $globals.SeduxDecoratedStore);
  234. $core.addMethod(
  235. $core.method({
  236. selector: "dispatch:next:",
  237. protocol: 'instance creation',
  238. fn: function (aDispatcher,aStore){
  239. var self=this;
  240. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  241. return $core.withContext(function($ctx1) {
  242. //>>excludeEnd("ctx");
  243. var $1;
  244. $1=self._new();
  245. $recv($1)._dispatch_next_(aDispatcher,aStore);
  246. return $recv($1)._yourself();
  247. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  248. }, function($ctx1) {$ctx1.fill(self,"dispatch:next:",{aDispatcher:aDispatcher,aStore:aStore},$globals.SeduxDecoratedStore.klass)});
  249. //>>excludeEnd("ctx");
  250. },
  251. //>>excludeStart("ide", pragmas.excludeIdeData);
  252. args: ["aDispatcher", "aStore"],
  253. source: "dispatch: aDispatcher next: aStore\x0a\x09^ self new\x0a\x09\x09dispatch: aDispatcher next: aStore;\x0a\x09\x09yourself",
  254. referencedClasses: [],
  255. //>>excludeEnd("ide");
  256. messageSends: ["dispatch:next:", "new", "yourself"]
  257. }),
  258. $globals.SeduxDecoratedStore.klass);
  259. });