spyne 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.travis.yml +2 -2
  2. package/karma.conf.js +18 -69
  3. package/lib/spyne.js +29752 -28672
  4. package/lib/spyne.min.js +1 -1
  5. package/lib/spyne.min.js.LICENSE.txt +9 -9
  6. package/package.json +21 -42
  7. package/src/spyne/channels/channel-fetch-class.js +25 -5
  8. package/src/spyne/channels/channel-payload-class.js +36 -23
  9. package/src/spyne/channels/channel-proxy.js +7 -5
  10. package/src/spyne/channels/channel.js +54 -28
  11. package/src/spyne/channels/channels-config.js +2 -4
  12. package/src/spyne/channels/{channels-delegator.js → channels-map.js} +25 -41
  13. package/src/spyne/channels/spyne-channel-lifecycle.js +1 -2
  14. package/src/spyne/channels/spyne-channel-route.js +21 -62
  15. package/src/spyne/channels/spyne-channel-ui.js +1 -2
  16. package/src/spyne/channels/spyne-channel-window.js +24 -35
  17. package/src/spyne/spyne-app.js +163 -0
  18. package/src/spyne/spyne-plugins.js +43 -40
  19. package/src/spyne/spyne.js +6 -157
  20. package/src/spyne/utils/channel-config-validator.js +0 -1
  21. package/src/spyne/utils/channel-fetch-util.js +1 -2
  22. package/src/spyne/utils/channel-payload-filter.js +9 -76
  23. package/src/spyne/utils/frp-tools.js +21 -1
  24. package/src/spyne/utils/gc.js +1 -1
  25. package/src/spyne/utils/route-channel-updater.js +0 -4
  26. package/src/spyne/utils/spyne-app-properties.js +183 -0
  27. package/src/spyne/utils/spyne-logger.js +18 -0
  28. package/src/spyne/utils/spyne-plugins-methods.js +97 -0
  29. package/src/spyne/utils/spyne-trait.js +2 -5
  30. package/src/spyne/utils/spyne-utils-channel-route-url.js +3 -8
  31. package/src/spyne/utils/spyne-utils-channel-route.js +6 -14
  32. package/src/spyne/utils/spyne-utils-channel-window.js +1 -3
  33. package/src/spyne/utils/viewstream-observables.js +2 -3
  34. package/src/spyne/views/dom-element-template.js +2 -7
  35. package/src/spyne/views/dom-element.js +0 -19
  36. package/src/spyne/views/view-stream-broadcaster.js +5 -10
  37. package/src/spyne/views/view-stream-element.js +1 -18
  38. package/src/spyne/views/view-stream-payload.js +31 -37
  39. package/src/spyne/views/view-stream-selector.js +3 -8
  40. package/src/spyne/views/view-stream.js +281 -297
  41. package/src/tests/channels/channel-fetch.test.js +102 -0
  42. package/src/tests/channels/channel-payload-class.test.js +14 -5
  43. package/src/tests/channels/channel-payload-filter.test.js +3 -28
  44. package/src/tests/channels/channel.test.js +38 -0
  45. package/src/tests/index.js +0 -1
  46. package/src/tests/index.test.js +6 -0
  47. package/src/tests/spyne-app.test.js +27 -0
  48. package/src/tests/spyne-plugin.test.js +13 -9
  49. package/src/tests/utils/plugins-methods.test.js +103 -0
  50. package/src/tests/utils/spyne-app-properties.test.js +11 -0
  51. package/webpack.config.js +19 -34
  52. package/lib/channel-action-filter.test.3516417154.js +0 -20
  53. package/lib/channel-dom.test.104366832.js +0 -20
  54. package/lib/channel-fetch-util.test.3506167575.js +0 -20
  55. package/lib/channel-payload-class.test.1081032524.js +0 -20
  56. package/lib/channel-payload-filter.test.977308429.js +0 -20
  57. package/lib/channel-route.test.3513636042.js +0 -20
  58. package/lib/channel-stream-item.test.119388071.js +0 -20
  59. package/lib/channel-ui.test.3778619579.js +0 -20
  60. package/lib/channel-util-dom.test.908537750.js +0 -20
  61. package/lib/commons.js +0 -49268
  62. package/lib/dom-el-selectors.test.1268485916.js +0 -20
  63. package/lib/dom-el-template.test.842696987.js +0 -20
  64. package/lib/dom-el.test.2045076905.js +0 -20
  65. package/lib/frp-tools.test.2503042868.js +0 -20
  66. package/lib/import.test.2658619365.js +0 -20
  67. package/lib/index.test.2372977745.js +0 -20
  68. package/lib/route-utils.test.273346057.js +0 -20
  69. package/lib/runtime.js +0 -172
  70. package/lib/spyne-plugin.test.301647328.js +0 -20
  71. package/lib/spyne.js.map +0 -1
  72. package/lib/url-utils.test.1931189114.js +0 -20
  73. package/lib/view-stream-broadcaster.test.1306675435.js +0 -20
  74. package/lib/view-stream-enhancer-loader.test.3617829096.js +0 -20
  75. package/lib/view-stream-enhancer.test.1053738169.js +0 -20
  76. package/lib/view-stream.test.573231784.js +0 -20
  77. package/src/spyne/channels/lifestream-payload.js +0 -56
  78. package/src/spyne/utils/channel-data-packet-generator.js +0 -200
  79. package/src/spyne/utils/channel-data-packet.js +0 -59
  80. package/src/spyne/utils/viewstream-dom-utils.js +0 -51
  81. package/src/spyne/views/view-stream-enhancer-loader.js +0 -70
@@ -1,6 +1,6 @@
1
1
  import { Channel } from './channel';
2
2
  import { ChannelFetchUtil } from '../utils/channel-fetch-util';
3
- import {path, pick, mergeDeepRight, defaultTo, reject, compose, isNil} from 'ramda';
3
+ import {path, pick, mergeDeepRight, all, allPass, either, values, defaultTo, reject, compose, isNil} from 'ramda';
4
4
 
5
5
  export class ChannelFetch extends Channel {
6
6
  /**
@@ -50,7 +50,11 @@ export class ChannelFetch extends Channel {
50
50
  constructor(name, props = {}) {
51
51
 
52
52
  // ALLOW FOR GENERIC MAP PROPERTY
53
+
54
+ ChannelFetch.validateMapMethod(props, name);
55
+
53
56
  if (props.map!==undefined){
57
+
54
58
  props.mapFn = props.map;
55
59
  }
56
60
  props.extendedActionsArr = [
@@ -61,6 +65,25 @@ export class ChannelFetch extends Channel {
61
65
  super(name, props);
62
66
  }
63
67
 
68
+ static validateMapMethod(props, name, testMode=false){
69
+ const isNotEmpty = arr=>arr.length>=1
70
+ const isNotFunction = val => typeof(val)!=='function';
71
+ const isUndefinedOrWrongType = either(isNil, isNotFunction)
72
+ const isUndefined = all(isUndefinedOrWrongType);
73
+ const isNotUndefinedAndIsNotEmpty = allPass([isUndefined, isNotEmpty])
74
+ const mapMethodIsInvalid = compose(isNotUndefinedAndIsNotEmpty,values, pick(['map', 'mapFn']))(props)
75
+
76
+ if (mapMethodIsInvalid){
77
+ if(testMode===false) {
78
+ console.warn(`Spyne Warning: The map method for ChannelFetch, ${name}, appears to be invalid`);
79
+ }
80
+ return false;
81
+ }
82
+
83
+ return true;
84
+
85
+ }
86
+
64
87
  onRegistered() {
65
88
  this.startFetch();
66
89
  }
@@ -86,12 +109,10 @@ export class ChannelFetch extends Channel {
86
109
  }
87
110
 
88
111
  onFetchReturned(streamItem) {
89
- let payload = this.createChannelPayloadItem(streamItem);
112
+ return this.createChannelPayloadItem(streamItem);
90
113
  }
91
114
 
92
115
  createChannelPayloadItem(payload, action = `${this.props.name}_DATA_EVENT`) {
93
- // console.log("FETCH ",this.props.name, {action,payload});
94
- // return new ChannelPayload(this.props.name, action, payload);
95
116
  this.sendChannelPayload(action, payload);
96
117
  }
97
118
 
@@ -101,7 +122,6 @@ export class ChannelFetch extends Channel {
101
122
  }
102
123
 
103
124
  consolidateAllFetchProps(options, props = this.props) {
104
- // let currentOptions = mergeRight({url}, options);
105
125
  let propsOptions = pick(['mapFn', 'url', 'header', 'body', 'mode', 'method', 'responseType', 'debug'], props);
106
126
  const mergeOptions = (o1, o2) => mergeDeepRight(o1, o2);
107
127
  const filterOutUndefined = reject(isNil);
@@ -4,14 +4,14 @@ import {
4
4
  fromPairs,
5
5
  toPairs,
6
6
  compose,
7
- mergeDeepRight,
8
- mergeRight,
9
- pathEq,
10
7
  includes,
11
8
  pickAll,
12
- __,
13
- lte, defaultTo, prop, is, mapObjIndexed,
9
+ lte,
10
+ defaultTo,
11
+ prop,
12
+ is
14
13
  } from 'ramda';
14
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
15
15
 
16
16
  export class ChannelPayload {
17
17
  /**
@@ -44,7 +44,8 @@ export class ChannelPayload {
44
44
 
45
45
  let channelPayloadItemObj = { channelName, action, srcElement, event };
46
46
  // Object.defineProperty(channelPayloadItemObj, 'payload', {get: () => clone(payload)});
47
- channelPayloadItemObj['payload'] = ChannelPayload.deepFreeze(payload);
47
+ const frozenPayload = ChannelPayload.deepFreeze(payload);
48
+ channelPayloadItemObj['payload'] = frozenPayload;
48
49
  /**
49
50
  * This is a convenience method that helps with destructuring by merging all properties.
50
51
  *
@@ -59,45 +60,57 @@ export class ChannelPayload {
59
60
  */
60
61
 
61
62
 
62
- const isDebugMode = pathEq(['Spyne','config', 'debug'], true)(window);
63
63
 
64
- if (isDebugMode === true){
65
- if (payload.hasOwnProperty('payload')){
64
+ if (SpyneAppProperties.debug === true){
65
+ if (Object.prototype.hasOwnProperty.call(payload, 'payload')){
66
66
  let payloadStr = JSON.stringify(payload);
67
67
  console.warn(`Spyne Warning: the following payload contains a nested payload property which may create conflicts: Action: ${action}, ${payloadStr}`);
68
68
  }
69
+
70
+ const channelActionsArr = SpyneAppProperties.getChannelActions(channel);
71
+
72
+ ChannelPayload.validateAction(action, channel, channelActionsArr);
73
+
74
+
69
75
  }
70
76
 
71
77
 
72
78
 
73
- channelPayloadItemObj.props = () => clone(mergeAll([
79
+ channelPayloadItemObj.clone = () => clone(mergeAll([
74
80
  {payload:ChannelPayload.deepClone(channelPayloadItemObj.payload)},
75
81
  channelPayloadItemObj.payload,
76
82
  { channel },
77
83
  { event: event },
84
+ {srcElement: srcElement},
78
85
  channelPayloadItemObj.srcElement, {
79
86
  action: channelPayloadItemObj.action }
80
87
  ]));
81
88
 
82
89
 
83
- const channelActionsArr = window.Spyne.getChannelActions(channel);
84
90
 
85
- ChannelPayload.validateAction(action, channel, channelActionsArr);
91
+ const channelPayloadItemObjProps = {
92
+ $dir: {
93
+ get: () => channelPayloadItemObj._dir,
94
+ set: (val) => channelPayloadItemObj._dir=val
95
+ }
96
+ }
97
+
98
+
86
99
 
87
100
  if (channel === 'CHANNEL_ROUTE') {
88
- channelPayloadItemObj['location'] = ChannelPayload.getLocationData();
101
+ //channelPayloadItemObj['location'] = ChannelPayload.getLocationData();
102
+ channelPayloadItemObjProps['location'] = {
103
+ get: ()=>ChannelPayload.getLocationData()
104
+ }
105
+ /* channelPayloadItemObjProps['routeData'] = {
106
+ get: ()=>prop('routeData', frozenPayload)
107
+ }
108
+ */
89
109
  }
90
- // return window.Spyne.createDataPacket(channelPayloadItemObj, ['channelName', 'action']);
91
110
 
92
111
  channelPayloadItemObj._dir = undefined;
93
112
 
94
- Object.defineProperties(channelPayloadItemObj, {
95
- $dir: {
96
- get: () => channelPayloadItemObj._dir,
97
- set: (val) => channelPayloadItemObj._dir=val
98
- }
99
-
100
- })
113
+ Object.defineProperties(channelPayloadItemObj, channelPayloadItemObjProps)
101
114
 
102
115
  if(timeLabel){
103
116
  console.timeEnd(timeLabel);
@@ -107,7 +120,7 @@ export class ChannelPayload {
107
120
 
108
121
  static validateAction(action, channel, arr) {
109
122
  let isInArr = includes(action, arr);
110
- if (isInArr === false && window.Spyne !== undefined) {
123
+ if (isInArr === false && SpyneAppProperties.initialized === true) {
111
124
  console.warn(`warning: Action: '${action}' is not registered within the ${channel} channel!`);
112
125
  }
113
126
  return isInArr;
@@ -150,7 +163,7 @@ export class ChannelPayload {
150
163
  try {
151
164
  Object.freeze(o);
152
165
  Object.getOwnPropertyNames(o).forEach(function(prop) {
153
- if (o.hasOwnProperty(prop)
166
+ if (Object.prototype.hasOwnProperty.call(o,prop)
154
167
  && elIsDomElement(o[prop]) === false
155
168
  && o[prop] !== null
156
169
  && (typeof o[prop] === "object" || typeof o[prop] === "function")
@@ -1,6 +1,8 @@
1
1
  import { Channel } from './channel';
2
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
2
3
  import { Subject, ReplaySubject, merge } from 'rxjs';
3
- import {includes, path} from 'ramda';
4
+ import {includes} from 'ramda';
5
+ import {delayCall} from '../utils/frp-tools';
4
6
 
5
7
  export class ChannelProxy extends Channel {
6
8
  /**
@@ -22,7 +24,7 @@ export class ChannelProxy extends Channel {
22
24
  this.subject$ = new Subject();
23
25
  this.replaySub$ = new ReplaySubject(1);
24
26
  this.observer$ = merge(this.subject$, this.replaySub$);
25
- const isDevMode = path(['Spyne', 'config', 'debug'], window) === true;
27
+ const isDevMode = SpyneAppProperties.debug;
26
28
  if (isDevMode === true){
27
29
  this.checkIfChannelIsStillProxy(name);
28
30
  }
@@ -36,14 +38,14 @@ export class ChannelProxy extends Channel {
36
38
  let name = channelName;
37
39
 
38
40
  const checkIfProxy=()=>{
39
- //console.log("CHANNELS ",window.Spyne.channels.listRegisteredChannels());
40
- let bool = includes(name, window.Spyne.channels.listRegisteredChannels());
41
+ let bool = includes(name, SpyneAppProperties.listRegisteredChannels());
41
42
  if (bool!==true){
42
43
  console.warn(`Spyne Warning: The channel, ${name} does not appear to be registered!`);
43
44
  }
44
45
  };
45
46
 
46
- window.setTimeout(checkIfProxy, 1000);
47
+ delayCall(checkIfProxy, 1000);
48
+
47
49
  }
48
50
 
49
51
  get replaySubject() {
@@ -1,6 +1,6 @@
1
1
  import { registeredStreamNames } from './channels-config';
2
2
  import { ChannelPayload } from './channel-payload-class';
3
- import { ChannelPayloadFilter} from '../utils/channel-payload-filter';
3
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
4
4
  import {RouteChannelUpdater} from '../utils/route-channel-updater';
5
5
  import { ReplaySubject, Subject } from 'rxjs';
6
6
  import {filter} from 'rxjs/operators';
@@ -18,10 +18,10 @@ import {
18
18
  always,
19
19
  fromPairs,
20
20
  path,
21
- assocPath,
21
+ isEmpty,
22
22
  equals,
23
23
  prop,
24
- apply,
24
+ propEq
25
25
  } from 'ramda';
26
26
  const rMap = require('ramda').map;
27
27
 
@@ -71,21 +71,28 @@ export class Channel {
71
71
  this.addRegisteredActions.bind(this);
72
72
  this.createChannelActionsObj(CHANNEL_NAME, props.extendedActionsArr);
73
73
  props.name = CHANNEL_NAME;
74
+ props.defaultActions = props.data!==undefined ? [`${props.name}_EVENT`] : [];
74
75
  this.props = props;
75
76
  this.props.isRegistered = false;
76
77
  this.props.isProxy = this.props.isProxy === undefined ? false : this.props.isProxy;
77
- this.props.sendCachedPayload = this.props.sendCachedPayload === undefined ? false : this.props.sendCachedPayload;
78
+ const defaultCachedPayloadBool = this.props['data']!==undefined;
79
+ this.props.sendCachedPayload = this.props.sendCachedPayload === undefined ? defaultCachedPayloadBool : this.props.sendCachedPayload;
78
80
  this.sendPayloadToRouteChannel = new RouteChannelUpdater(this);
79
81
  this.createChannelActionMethods();
80
- this.streamsController = window.Spyne.channels;// getGlobalParam('streamsController');
82
+ this.streamsController = SpyneAppProperties.channelsMap;
81
83
  let observer$ = this.getMainObserver();
82
-
84
+ this.checkForPersistentDataMode = Channel.checkForPersistentDataMode.bind(this);
83
85
  this.observer$ = this.props['observer'] = observer$;
84
86
  let dispatcherStream$ = this.streamsController.getStream('DISPATCHER');
85
- dispatcherStream$.subscribe((val) => this.onReceivedObservable(val));
87
+ const payloadPredByChannelName = propEq('name', props.name)
88
+ dispatcherStream$.pipe(filter(payloadPredByChannelName)).subscribe((val) => this.onReceivedObservable(val));
86
89
  }
87
90
 
88
91
  getMainObserver() {
92
+ if (this.streamsController === undefined){
93
+ console.warn(`Spyne Warning: The following channel, ${this.props.name}, appears to be registered before Spyne has been initialized.`)
94
+ }
95
+
89
96
  let proxyExists = this.streamsController.testStream(this.props.name);
90
97
 
91
98
  if (proxyExists === true) {
@@ -109,7 +116,13 @@ export class Channel {
109
116
  * <p>This method is empty and is called as soon as the Channel has been registered.</p>
110
117
  * <p>Tasks such as subscribing to other channels, and sending initial payloads can be added here.</p>
111
118
  */
112
- onRegistered(){
119
+ onRegistered(props=this.props){
120
+ if(props.data!==undefined){
121
+ const action = Object.keys(this.channelActions)[0];
122
+ //console.log("CHANNELS ACTIONS IS ",this.channelActions);
123
+ //Object(this.channelActions).keys[0];
124
+ this.sendChannelPayload(action, props.data);
125
+ }
113
126
 
114
127
  }
115
128
 
@@ -136,7 +149,7 @@ export class Channel {
136
149
  traits = [traits];
137
150
  }
138
151
  const addTrait=(TraitClass)=>{
139
- new TraitClass(this);
152
+ return new TraitClass(this);
140
153
  };
141
154
 
142
155
  traits.forEach(addTrait);
@@ -151,12 +164,39 @@ export class Channel {
151
164
  initializeStream() {
152
165
  this.checkForTraits();
153
166
  this.onChannelInitialized();
167
+ this.checkForPersistentDataMode();
154
168
  this.onRegistered();
155
169
  this.props.isRegistered = true;
156
170
 
157
171
 
158
172
  }
159
173
 
174
+ static checkForPersistentDataMode(props=this.props, actionsObj=this.channelActions){
175
+ const actionsObjIsEmpty = isEmpty(actionsObj);
176
+ const dataIsAdded = prop('data', props) !== undefined;
177
+ const autoSetToCachedPayload = actionsObjIsEmpty === true && dataIsAdded === true;
178
+ const setDefaultActionsObj = ()=>{
179
+ const {name} = props;
180
+ const actionStr = `${name}_EVENT`;
181
+ return {
182
+ [actionStr] : actionStr
183
+ }
184
+ }
185
+
186
+ if (autoSetToCachedPayload){
187
+ props.sendCachedPayload = true;
188
+ actionsObj = setDefaultActionsObj();
189
+
190
+ if (this.channelActions!==undefined){
191
+ this.channelActions = actionsObj;
192
+ }
193
+ }
194
+
195
+
196
+ //console.log("PROPS IS ",{actionsObjIsEmpty, dataIsAdded, props, actionsObj}, this.channelActions)
197
+ return {props, actionsObj};
198
+ }
199
+
160
200
  setTrace(bool) {
161
201
  }
162
202
 
@@ -219,7 +259,11 @@ export class Channel {
219
259
  *
220
260
  */
221
261
  addRegisteredActions() {
222
- return [];
262
+ let arr = []
263
+ if (path(['props','data'], this)){
264
+ arr = [`${this.props.name}_EVENT`];
265
+ }
266
+ return arr;
223
267
  }
224
268
 
225
269
  onReceivedObservable(obj) {
@@ -356,24 +400,6 @@ export class Channel {
356
400
  return fn(CHANNEL_NAME);
357
401
  }
358
402
 
359
- /**
360
- *
361
- * Wraps window.setTimeout with a check to see if "this" ViewStream element and its props property still exists
362
- * @property {function} fn - = 'function'; The local method that is to be called.
363
- * @property {number} ms - = 0; The time, in milleseconds, for the timeout.
364
- * @property {boolean} bind - = false; When true, will bind the method to 'this'.
365
- *
366
- */
367
-
368
- setTimeout(fn, ms=0, bind=false){
369
- const timeoutMethod = (...args)=>{
370
- if (this!==undefined && this.props!==undefined){
371
- const methodFn = bind===true ? fn.bind(this) : fn;
372
- apply(methodFn, args);
373
- }
374
- }
375
- window.setTimeout(timeoutMethod, ms);
376
- }
377
403
 
378
404
 
379
405
 
@@ -1,13 +1,11 @@
1
- // import Spyne from '../spyne';
2
- import { arrFromMapKeys } from '../utils/frp-tools';
3
-
1
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
4
2
  import {compose, path, is} from 'ramda';
5
3
  const Observable = require('rxjs');
6
4
  const Subject = require('rxjs');
7
5
 
8
6
  // console.log('channels config loaded ',R,Rx);
9
7
  let registeredStreamNames = () => ({
10
- includes: () => window.Spyne !== undefined ? arrFromMapKeys(window.Spyne.channels.map) : ['CHANNEL_ROUTE', 'CHANNEL_UI', 'CHANNEL_WINDOW', 'DISPATCHER']
8
+ includes: () => SpyneAppProperties.initialized === true ? SpyneAppProperties.listRegisteredChannels() : ['CHANNEL_ROUTE', 'CHANNEL_UI', 'CHANNEL_WINDOW', 'DISPATCHER']
11
9
 
12
10
  });
13
11
 
@@ -1,19 +1,16 @@
1
- // import {baseCoreMixins} from '../utils/mixins/base-core-mixins';
2
- // import {BaseStreamsMixins} from '../utils/mixins/base-streams-mixins';
3
1
  import { SpyneChannelRoute } from './spyne-channel-route';
4
2
  import { SpyneChannelUI } from './spyne-channel-ui';
5
3
  import { SpyneChannelWindow } from './spyne-channel-window';
6
4
  import { SpyneChannelLifecycle } from './spyne-channel-lifecycle';
7
- import { validate } from '../utils/channel-config-validator';
8
5
 
9
6
  import { Subject } from 'rxjs';
10
7
  import { ChannelProxy } from './channel-proxy';
11
- import {propEq, pluck, prop, filter, pathEq, clone, reject, compose, join} from 'ramda';
8
+ import {propEq, pluck, prop, filter, pathEq, reject, compose, join} from 'ramda';
12
9
  const rMap = require('ramda').map;
10
+ const _map = new Map();
13
11
 
14
- // import * as R from 'ramda';
15
12
 
16
- export class ChannelsDelegator {
13
+ export class ChannelsMap {
17
14
  /**
18
15
  * @module ChannelsDelegator
19
16
  * @type internal
@@ -28,14 +25,13 @@ export class ChannelsDelegator {
28
25
 
29
26
  constructor() {
30
27
  this.addMixins();
31
- this.map = new Map();
32
-
33
- // console.log('Rx is ',Rx);
34
- // console.log('RX IS ', Subject);
35
- this.map.set('DISPATCHER', new Subject());
36
- this.listRegisteredChannels = ChannelsDelegator.listRegisteredChannels.bind(this);
37
- this.getChannelsList = ChannelsDelegator.getChannelsList.bind(this);
38
- //window.setTimeout(this.checkForMissingChannels.bind(this), 8000);
28
+ _map.set('DISPATCHER', new Subject());
29
+ this.listRegisteredChannels = ChannelsMap.listRegisteredChannels.bind(this);
30
+ this.getChannelsList = ChannelsMap.getChannelsList.bind(this);
31
+ }
32
+
33
+ get map(){
34
+ return _map;
39
35
  }
40
36
 
41
37
  static getChannelsList() {
@@ -44,7 +40,7 @@ export class ChannelsDelegator {
44
40
  let val = k[1].constructor.name;
45
41
  return { key, val };
46
42
  };
47
- return Array.from(window.Spyne.channels.map, proxyMapFn);
43
+ return Array.from(_map, proxyMapFn);
48
44
  }
49
45
 
50
46
  static listRegisteredChannels(showOnlyProxies = false) {
@@ -69,84 +65,72 @@ export class ChannelsDelegator {
69
65
  let channels = compose(join(', '), rMap(prop('key')))(filterProxyArr);
70
66
  let filterPrefixWarning = `Spyne Warning: The following ${channelStr} not been initialized: ${channels}`;
71
67
  console.warn(filterPrefixWarning);
72
- // console.log("FILTER PROXY WARNING ",filterProxyArr);
73
68
  }
74
69
 
75
- // console.log(filterProxy(proxyMap),' proxyMap ', proxyMap);
76
70
  }
77
71
 
78
72
  init() {
79
73
  this.createMainStreams();
80
74
  }
81
75
 
82
- createObserver(obj) {
83
- // RIGHT NOW THIS CREATES THE DISPATCHER STREAM
84
- validate(obj.validations, obj.init);
85
- this.map.set(obj.init.name, obj.init.observable());
86
- }
87
76
 
88
77
  createMainStreams() {
89
78
  this.routeStream = new SpyneChannelRoute();
90
- this.map.set('CHANNEL_ROUTE', this.routeStream);
91
- window.Spyne.config.channels['CHANNEL_ROUTE'] = {};
79
+ _map.set('CHANNEL_ROUTE', this.routeStream);
92
80
 
93
81
  this.uiStream = new SpyneChannelUI();
94
- this.map.set('CHANNEL_UI', this.uiStream);
95
- window.Spyne.config.channels['CHANNEL_UI'] = {};
82
+ _map.set('CHANNEL_UI', this.uiStream);
96
83
 
97
84
  this.domStream = new SpyneChannelWindow();
98
- this.map.set('CHANNEL_WINDOW', this.domStream);
99
- window.Spyne.config.channels['CHANNEL_WINDOW'] = {};
100
-
85
+ _map.set('CHANNEL_WINDOW', this.domStream);
86
+
101
87
  this.viewStreamLifecycle = new SpyneChannelLifecycle();
102
- this.map.set('CHANNEL_LIFECYCLE', this.viewStreamLifecycle);
103
- window.Spyne.config.channels['CHANNEL_LIFECYCLE'] = {};
88
+ _map.set('CHANNEL_LIFECYCLE', this.viewStreamLifecycle);
104
89
 
105
90
  this.routeStream.initializeStream();
106
91
  this.domStream.initializeStream();
107
92
  }
108
93
 
109
94
  addKeyEvent(key) {
110
- this.map.get('UI').addKeyEvent(key);
95
+ _map.get('UI').addKeyEvent(key);
111
96
  }
112
97
 
113
98
  registerStream(val) {
114
99
  let name = val.channelName;
115
- const nameExists = this.map.has(name);
100
+ const nameExists = _map.has(name);
116
101
  if (nameExists){
117
- const isAlreadyRegisterd = compose(pathEq(['props', 'isRegistered'], true))(this.map.get(name));
102
+ const isAlreadyRegisterd = compose(pathEq(['props', 'isRegistered'], true))(_map.get(name));
118
103
  if(isAlreadyRegisterd){
119
104
  console.warn(`Spyne Warning: The Channel, ${name}, has already been registered!`);
120
105
  return;
121
106
  }
122
107
  }
123
108
 
124
- window.Spyne.config.channels[name] = {};
125
109
 
126
- this.map.set(name, val);
110
+ _map.set(name, val);
127
111
  val.initializeStream();
128
112
  }
129
113
 
130
114
  getChannelActions(str) {
131
- return this.map.get(str).addRegisteredActions();
115
+ return _map.get(str).addRegisteredActions();
132
116
  }
133
117
 
134
118
  getProxySubject(name, isReplaySubject = false) {
135
119
  let subjectType = isReplaySubject === true ? 'replaySubject' : 'subject';
136
120
 
137
- return this.map.get(name)[subjectType];
121
+ return _map.get(name)[subjectType];
138
122
  }
139
123
 
140
124
  testStream(name) {
141
- return this.map.get(name) !== undefined;
125
+ return _map.get(name) !== undefined;
142
126
  }
143
127
 
144
128
  getStream(name) {
145
129
  if (this.testStream(name) === false) {
146
- this.map.set(name, new ChannelProxy(name));
130
+ _map.set(name, new ChannelProxy(name));
147
131
  }
148
132
 
149
- return this.map.get(name);
133
+ return _map.get(name);
150
134
  }
151
135
 
152
136
  addMixins() {
@@ -1,5 +1,4 @@
1
1
  import { Channel } from './channel';
2
- import {prop} from 'ramda';
3
2
 
4
3
  export class SpyneChannelLifecycle extends Channel {
5
4
  /**
@@ -30,7 +29,7 @@ export class SpyneChannelLifecycle extends Channel {
30
29
  }
31
30
 
32
31
  onViewStreamInfo(obj) {
33
- let {data, action, srcElement} = obj;
32
+ let {action, srcElement} = obj;
34
33
  let payload = srcElement;
35
34
  payload['action'] = action;
36
35
  this.onSendEvent(action, payload);