@guanghechen/observable 6.0.1 → 6.0.3
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/CHANGELOG.md +31 -0
- package/lib/cjs/index.cjs +13 -9
- package/lib/esm/index.mjs +14 -10
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,37 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.0.3](https://github.com/guanghechen/sora/compare/@guanghechen/observable@6.0.2...@guanghechen/observable@6.0.3) (2024-03-10)
|
|
7
|
+
|
|
8
|
+
### Performance Improvements
|
|
9
|
+
|
|
10
|
+
- 🎨 add @guanghechen/monitor back
|
|
11
|
+
([4c75f05](https://github.com/guanghechen/sora/commit/4c75f05441f57eb2428c086aea20c733f4a730c5))
|
|
12
|
+
- 🎨 format codes
|
|
13
|
+
([a953c67](https://github.com/guanghechen/sora/commit/a953c67ba19389b6b14bc829361d9ca406c24059))
|
|
14
|
+
|
|
15
|
+
# Change Log
|
|
16
|
+
|
|
17
|
+
All notable changes to this project will be documented in this file. See
|
|
18
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
19
|
+
|
|
20
|
+
## [6.0.2](https://github.com/guanghechen/sora/compare/@guanghechen/observable@6.0.1...@guanghechen/observable@6.0.2) (2024-03-09)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- 🐛 notify current value to subscriber even the observable has been disposed
|
|
25
|
+
([235d145](https://github.com/guanghechen/sora/commit/235d145c7f159f66a4a1f407e7156e601d85f1e4))
|
|
26
|
+
|
|
27
|
+
### Performance Improvements
|
|
28
|
+
|
|
29
|
+
- :art: format codes
|
|
30
|
+
([177eb54](https://github.com/guanghechen/sora/commit/177eb5407fe9209269541a327d42084901a63090))
|
|
31
|
+
|
|
32
|
+
# Change Log
|
|
33
|
+
|
|
34
|
+
All notable changes to this project will be documented in this file. See
|
|
35
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
36
|
+
|
|
6
37
|
## 6.0.1 (2024-03-09)
|
|
7
38
|
|
|
8
39
|
### Performance Improvements
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -52,8 +52,11 @@ class Observable extends disposable.BatchDisposable {
|
|
|
52
52
|
continue;
|
|
53
53
|
batcher.run(() => item.subscriber.dispose());
|
|
54
54
|
}
|
|
55
|
+
for (const item of this._subscribers)
|
|
56
|
+
item.inactive = true;
|
|
55
57
|
this._subscribers.length = 0;
|
|
56
|
-
batcher.summary();
|
|
58
|
+
batcher.summary('[observable] Encountered errors while disposing.');
|
|
59
|
+
batcher.cleanup();
|
|
57
60
|
}
|
|
58
61
|
getSnapshot() {
|
|
59
62
|
return this._value;
|
|
@@ -76,12 +79,13 @@ class Observable extends disposable.BatchDisposable {
|
|
|
76
79
|
subscribe(subscriber) {
|
|
77
80
|
if (subscriber.disposed)
|
|
78
81
|
return noopUnsubscribable;
|
|
82
|
+
const prevValue = this._lastNotifiedValue;
|
|
83
|
+
const value = this._value;
|
|
79
84
|
if (this.disposed) {
|
|
85
|
+
subscriber.next(value, prevValue);
|
|
80
86
|
subscriber.dispose();
|
|
81
87
|
return noopUnsubscribable;
|
|
82
88
|
}
|
|
83
|
-
const prevValue = this._lastNotifiedValue;
|
|
84
|
-
const value = this._value;
|
|
85
89
|
this._flush();
|
|
86
90
|
const item = { subscriber, inactive: false };
|
|
87
91
|
this._subscribers.push(item);
|
|
@@ -134,7 +138,8 @@ class Observable extends disposable.BatchDisposable {
|
|
|
134
138
|
continue;
|
|
135
139
|
batcher.run(() => subscriber.subscriber.next(value, prevValue));
|
|
136
140
|
}
|
|
137
|
-
batcher.summary();
|
|
141
|
+
batcher.summary('[observable] Encountered errors while notifying subscribers.');
|
|
142
|
+
batcher.cleanup();
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
|
|
@@ -181,13 +186,12 @@ class Ticker extends Observable {
|
|
|
181
186
|
}
|
|
182
187
|
if (observable.disposed)
|
|
183
188
|
return noopUnobservable;
|
|
184
|
-
const subscriber = new Subscriber({
|
|
185
|
-
onNext: () => this.tick(),
|
|
186
|
-
onDispose: () => unsubscribable.unsubscribe(),
|
|
187
|
-
});
|
|
189
|
+
const subscriber = new Subscriber({ onNext: () => this.tick() });
|
|
188
190
|
const unsubscribable = observable.subscribe(subscriber);
|
|
191
|
+
const disposable$1 = new disposable.Disposable(() => unsubscribable.unsubscribe());
|
|
189
192
|
this.registerDisposable(subscriber);
|
|
190
|
-
|
|
193
|
+
this.registerDisposable(disposable$1);
|
|
194
|
+
return { unobserve: () => disposable$1.dispose() };
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchDisposable, SafeBatchHandler } from '@guanghechen/disposable';
|
|
1
|
+
import { BatchDisposable, SafeBatchHandler, Disposable } from '@guanghechen/disposable';
|
|
2
2
|
export * from '@guanghechen/observable.types';
|
|
3
3
|
|
|
4
4
|
const noop = (..._args) => { };
|
|
@@ -50,8 +50,11 @@ class Observable extends BatchDisposable {
|
|
|
50
50
|
continue;
|
|
51
51
|
batcher.run(() => item.subscriber.dispose());
|
|
52
52
|
}
|
|
53
|
+
for (const item of this._subscribers)
|
|
54
|
+
item.inactive = true;
|
|
53
55
|
this._subscribers.length = 0;
|
|
54
|
-
batcher.summary();
|
|
56
|
+
batcher.summary('[observable] Encountered errors while disposing.');
|
|
57
|
+
batcher.cleanup();
|
|
55
58
|
}
|
|
56
59
|
getSnapshot() {
|
|
57
60
|
return this._value;
|
|
@@ -74,12 +77,13 @@ class Observable extends BatchDisposable {
|
|
|
74
77
|
subscribe(subscriber) {
|
|
75
78
|
if (subscriber.disposed)
|
|
76
79
|
return noopUnsubscribable;
|
|
80
|
+
const prevValue = this._lastNotifiedValue;
|
|
81
|
+
const value = this._value;
|
|
77
82
|
if (this.disposed) {
|
|
83
|
+
subscriber.next(value, prevValue);
|
|
78
84
|
subscriber.dispose();
|
|
79
85
|
return noopUnsubscribable;
|
|
80
86
|
}
|
|
81
|
-
const prevValue = this._lastNotifiedValue;
|
|
82
|
-
const value = this._value;
|
|
83
87
|
this._flush();
|
|
84
88
|
const item = { subscriber, inactive: false };
|
|
85
89
|
this._subscribers.push(item);
|
|
@@ -132,7 +136,8 @@ class Observable extends BatchDisposable {
|
|
|
132
136
|
continue;
|
|
133
137
|
batcher.run(() => subscriber.subscriber.next(value, prevValue));
|
|
134
138
|
}
|
|
135
|
-
batcher.summary();
|
|
139
|
+
batcher.summary('[observable] Encountered errors while notifying subscribers.');
|
|
140
|
+
batcher.cleanup();
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
|
|
@@ -179,13 +184,12 @@ class Ticker extends Observable {
|
|
|
179
184
|
}
|
|
180
185
|
if (observable.disposed)
|
|
181
186
|
return noopUnobservable;
|
|
182
|
-
const subscriber = new Subscriber({
|
|
183
|
-
onNext: () => this.tick(),
|
|
184
|
-
onDispose: () => unsubscribable.unsubscribe(),
|
|
185
|
-
});
|
|
187
|
+
const subscriber = new Subscriber({ onNext: () => this.tick() });
|
|
186
188
|
const unsubscribable = observable.subscribe(subscriber);
|
|
189
|
+
const disposable = new Disposable(() => unsubscribable.unsubscribe());
|
|
187
190
|
this.registerDisposable(subscriber);
|
|
188
|
-
|
|
191
|
+
this.registerDisposable(disposable);
|
|
192
|
+
return { unobserve: () => disposable.dispose() };
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
195
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/observable",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
7
7
|
},
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/observable@6.0.
|
|
10
|
+
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/observable@6.0.2",
|
|
11
11
|
"directory": "packages/observable"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/observable@6.0.
|
|
13
|
+
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/observable@6.0.2/packages/observable#readme",
|
|
14
14
|
"keywords": [
|
|
15
15
|
"observable"
|
|
16
16
|
],
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@guanghechen/disposable": "^1.0.0-alpha.
|
|
37
|
+
"@guanghechen/disposable": "^1.0.0-alpha.4",
|
|
38
38
|
"@guanghechen/error.types": "^1.0.1",
|
|
39
39
|
"@guanghechen/observable.types": "^6.0.1"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "edc5a1b997fac81f96f1ba03200a13b829b3e91d"
|
|
42
42
|
}
|