angelia.io 3.4.83 → 3.4.84
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/client/index.js +12 -6
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -308,9 +308,13 @@ export default class Client {
|
|
|
308
308
|
Promise.resolve().then(this.send)
|
|
309
309
|
}
|
|
310
310
|
if (c) {
|
|
311
|
-
|
|
311
|
+
const { i, promise } = this.callback(c)
|
|
312
|
+
this.messages.push([k, v, i])
|
|
313
|
+
return promise
|
|
312
314
|
} else if (typeof v === 'function') {
|
|
313
|
-
|
|
315
|
+
const { i, promise } = this.callback(v)
|
|
316
|
+
this.messages.push([k, this.null, i])
|
|
317
|
+
return promise
|
|
314
318
|
} else if (v !== null && v !== undefined) {
|
|
315
319
|
this.messages.push([k, v])
|
|
316
320
|
} else {
|
|
@@ -355,9 +359,11 @@ export default class Client {
|
|
|
355
359
|
// PRIVATE API
|
|
356
360
|
|
|
357
361
|
callback(c) {
|
|
362
|
+
let resolve
|
|
363
|
+
const promise = new Promise(r => (resolve = r))
|
|
358
364
|
let i = this.callbacks.length
|
|
359
|
-
this.callbacks[i] = c
|
|
360
|
-
return i
|
|
365
|
+
this.callbacks[i] = (...args) => resolve(c(...args))
|
|
366
|
+
return { i, promise }
|
|
361
367
|
}
|
|
362
368
|
oncallback(d) {
|
|
363
369
|
this.callbacks[d[0]](...d[1])
|
|
@@ -374,7 +380,7 @@ export default class Client {
|
|
|
374
380
|
e[2]
|
|
375
381
|
? (...d) => {
|
|
376
382
|
this.emit('', [e[2], d])
|
|
377
|
-
|
|
383
|
+
}
|
|
378
384
|
: null,
|
|
379
385
|
)
|
|
380
386
|
}
|
|
@@ -390,7 +396,7 @@ export default class Client {
|
|
|
390
396
|
e[2]
|
|
391
397
|
? (...d) => {
|
|
392
398
|
this.emit('', [e[2], d])
|
|
393
|
-
|
|
399
|
+
}
|
|
394
400
|
: null,
|
|
395
401
|
)
|
|
396
402
|
}
|