@nxtedition/deepstream.io-client-js 24.0.10 → 24.0.11

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": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.0.10",
3
+ "version": "24.0.11",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -172,16 +172,22 @@ class Record {
172
172
  }
173
173
 
174
174
  // TODO (fix): timeout + signal
175
- when(stateOrNull) {
175
+ async when(stateOrNil, optionsOrNil) {
176
176
  invariant(this._refs > 0, 'missing refs')
177
177
 
178
- const state = stateOrNull == null ? C.RECORD_STATE.SERVER : stateOrNull
178
+ if (stateOrNil != null && stateOrNil === 'object') {
179
+ optionsOrNil = stateOrNil
180
+ stateOrNil = optionsOrNil?.state
181
+ }
182
+
183
+ const signal = optionsOrNil?.signal
184
+ const state = stateOrNil ?? C.RECORD_STATE.SERVER
179
185
 
180
186
  if (!Number.isFinite(state) || state < 0) {
181
187
  throw new Error('invalid argument: state')
182
188
  }
183
189
 
184
- return new Promise((resolve) => {
190
+ await new Promise((resolve) => {
185
191
  if (this._state >= state) {
186
192
  resolve(null)
187
193
  return
@@ -201,6 +207,8 @@ class Record {
201
207
  this.ref()
202
208
  this.subscribe(onUpdate)
203
209
  })
210
+
211
+ signal?.throwIfAborted()
204
212
  }
205
213
 
206
214
  update(pathOrUpdater, updaterOrNil) {