shelving 1.150.13 → 1.150.15
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/sequence/DeferredSequence.d.ts +2 -0
- package/sequence/DeferredSequence.js +11 -3
- package/store/Store.d.ts +1 -1
- package/store/Store.js +7 -2
package/package.json
CHANGED
|
@@ -20,6 +20,8 @@ export declare class DeferredSequence<T = void> extends AbstractSequence<T, void
|
|
|
20
20
|
/** Reject the current deferred in the sequence. */
|
|
21
21
|
reject(reason: unknown): void;
|
|
22
22
|
private _nextReason;
|
|
23
|
+
/** Cancel the current resolution or rejection. */
|
|
24
|
+
cancel(): void;
|
|
23
25
|
/** Fulfill the current deferred by resolving or rejecting it. */
|
|
24
26
|
private _fulfill;
|
|
25
27
|
next(): Promise<IteratorResult<T, void>>;
|
|
@@ -33,17 +33,25 @@ export class DeferredSequence extends AbstractSequence {
|
|
|
33
33
|
queueMicrotask(() => this._fulfill());
|
|
34
34
|
}
|
|
35
35
|
_nextReason = _NOVALUE;
|
|
36
|
+
/** Cancel the current resolution or rejection. */
|
|
37
|
+
cancel() {
|
|
38
|
+
this._nextValue = _NOVALUE;
|
|
39
|
+
this._nextReason = _NOVALUE;
|
|
40
|
+
}
|
|
36
41
|
/** Fulfill the current deferred by resolving or rejecting it. */
|
|
37
42
|
_fulfill() {
|
|
38
43
|
const { _deferred, _nextReason, _nextValue } = this;
|
|
39
|
-
this._deferred = undefined;
|
|
40
44
|
this._nextReason = _NOVALUE;
|
|
41
45
|
this._nextValue = _NOVALUE;
|
|
42
46
|
if (_deferred) {
|
|
43
|
-
if (_nextReason !== _NOVALUE)
|
|
47
|
+
if (_nextReason !== _NOVALUE) {
|
|
48
|
+
this._deferred = undefined;
|
|
44
49
|
_deferred.reject(_nextReason);
|
|
45
|
-
|
|
50
|
+
}
|
|
51
|
+
else if (_nextValue !== _NOVALUE) {
|
|
52
|
+
this._deferred = undefined;
|
|
46
53
|
_deferred.resolve(_nextValue);
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
// Implement `AsyncIterator`
|
package/store/Store.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class Store<T> implements AsyncIterable<T> {
|
|
|
18
18
|
readonly next: DeferredSequence<T>;
|
|
19
19
|
/** Current value of the store (or throw a promise that resolves when this store receives its next value or error). */
|
|
20
20
|
get value(): T;
|
|
21
|
-
set value(value: T);
|
|
21
|
+
set value(value: T | typeof NONE);
|
|
22
22
|
private _value;
|
|
23
23
|
/** Is there a current value, or is it still loading. */
|
|
24
24
|
get loading(): boolean;
|
package/store/Store.js
CHANGED
|
@@ -25,8 +25,13 @@ export class Store {
|
|
|
25
25
|
}
|
|
26
26
|
set value(value) {
|
|
27
27
|
this._reason = undefined;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (value === NONE) {
|
|
29
|
+
this._time = undefined;
|
|
30
|
+
this._value = value;
|
|
31
|
+
this.next.cancel();
|
|
32
|
+
}
|
|
33
|
+
else if (this._value === NONE || !this.equal(value, this._value)) {
|
|
34
|
+
this._time = Date.now();
|
|
30
35
|
this._value = value;
|
|
31
36
|
this.next.resolve(value);
|
|
32
37
|
}
|