@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 +1 -1
- package/src/record/record.js +11 -3
package/package.json
CHANGED
package/src/record/record.js
CHANGED
|
@@ -172,16 +172,22 @@ class Record {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// TODO (fix): timeout + signal
|
|
175
|
-
when(
|
|
175
|
+
async when(stateOrNil, optionsOrNil) {
|
|
176
176
|
invariant(this._refs > 0, 'missing refs')
|
|
177
177
|
|
|
178
|
-
|
|
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
|
-
|
|
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) {
|