neo.mjs 4.0.72 → 4.0.73

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.0.72",
3
+ "version": "4.0.73",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -78,6 +78,14 @@ const DefaultConfig = {
78
78
  * @type Boolean
79
79
  */
80
80
  isInsideSiesta: false,
81
+ /**
82
+ * delay in ms for the worker.Manager:loadApplication() call
83
+ * @default 20
84
+ * @memberOf! module:Neo
85
+ * @name config.loadApplicationDelay
86
+ * @type Number
87
+ */
88
+ loadApplicationDelay: 20,
81
89
  /**
82
90
  * Used by Intl.DateTimeFormat, for details take a look at:
83
91
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
@@ -1099,8 +1099,8 @@ class Base extends CoreBase {
1099
1099
  * If the toRemoveArray is used, then the index is not used for removing, the entries are found by key and removed from where they are.
1100
1100
  * If index is not passed, toAddArray is appended to the Collection.
1101
1101
  * @param {Number|null} index
1102
- * @param {Number|Array} [removeCountOrToRemoveArray]
1103
- * @param {Array| Object} [toAddArray]
1102
+ * @param {Number|Object[]} [removeCountOrToRemoveArray]
1103
+ * @param {Object|Object[]} [toAddArray]
1104
1104
  * @returns {Object} An object containing the addedItems & removedItems arrays
1105
1105
  */
1106
1106
  splice(index, removeCountOrToRemoveArray, toAddArray) {
@@ -246,10 +246,7 @@ class Base extends CoreBase {
246
246
  let message = me.sendMessage(dest, opts, transfer),
247
247
  msgId = message.id;
248
248
 
249
- me.promises[msgId] = {
250
- resolve,
251
- reject
252
- };
249
+ me.promises[msgId] = { reject, resolve };
253
250
  });
254
251
  }
255
252
 
@@ -252,7 +252,7 @@ class Manager extends Base {
252
252
  if (me.constructedThreads === me.activeWorkers) {
253
253
  NeoConfig.appPath && setTimeout(() => { // better save than sorry => all remotes need to be registered
254
254
  me.loadApplication(NeoConfig.appPath);
255
- }, 20);
255
+ }, NeoConfig.loadApplicationDelay);
256
256
  }
257
257
  }
258
258
 
@@ -52,7 +52,6 @@ class RemoteMethodAccess extends Base {
52
52
  if (remote.destination === Neo.workerId) {
53
53
  let me = this,
54
54
  className = remote.className,
55
- exists = false,
56
55
  methods = remote.methods,
57
56
  pkg = Neo.ns(className, true);
58
57
 
@@ -63,15 +62,8 @@ class RemoteMethodAccess extends Base {
63
62
 
64
63
  if (!pkg[method] ) {
65
64
  pkg[method] = me.generateRemote(remote, method);
66
- } else {
67
- exists = true;
68
65
  }
69
66
  });
70
-
71
- // todo: inspect if this can get removed
72
- if (!exists && Neo.workerId !== 'main') {
73
- me.fire('remoteregistered', remote);
74
- }
75
67
  }
76
68
  }
77
69
 
@@ -251,4 +251,28 @@ StartTest(t => {
251
251
  t.isStrict(collection3.getCount(), 5, 'collection3 count is 5');
252
252
  t.isStrict(collection3.allItems.getCount(), 9, 'collection3 allItems count is 9');
253
253
  });
254
+
255
+ t.it('Add & remove at same time', t => {
256
+ collection = Neo.create(Collection, {
257
+ items: [
258
+ {id: 'a'},
259
+ {id: 'b'},
260
+ {id: 'c'},
261
+ {id: 'd'},
262
+ {id: 'e'},
263
+ {id: 'f'}
264
+ ]
265
+ });
266
+
267
+ collection.splice(2, [{id: 'a'}, {id: 'd'}, {id: 'f'}], [{id: 'x'}, {id: 'y'}, {id: 'z'}]);
268
+
269
+ t.isDeeplyStrict(collection.getRange(), [
270
+ {id: 'b'},
271
+ {id: 'c'},
272
+ {id: 'x'},
273
+ {id: 'y'},
274
+ {id: 'z'},
275
+ {id: 'e'}
276
+ ], 'collection.getRange()');
277
+ });
254
278
  });