@guanghechen/observable 6.0.1 → 6.0.2
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 +17 -0
- package/lib/cjs/index.cjs +7 -7
- package/lib/esm/index.mjs +8 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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.2](https://github.com/guanghechen/sora/compare/@guanghechen/observable@6.0.1...@guanghechen/observable@6.0.2) (2024-03-09)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- 🐛 notify current value to subscriber even the observable has been disposed
|
|
11
|
+
([235d145](https://github.com/guanghechen/sora/commit/235d145c7f159f66a4a1f407e7156e601d85f1e4))
|
|
12
|
+
|
|
13
|
+
### Performance Improvements
|
|
14
|
+
|
|
15
|
+
- :art: format codes
|
|
16
|
+
([177eb54](https://github.com/guanghechen/sora/commit/177eb5407fe9209269541a327d42084901a63090))
|
|
17
|
+
|
|
18
|
+
# Change Log
|
|
19
|
+
|
|
20
|
+
All notable changes to this project will be documented in this file. See
|
|
21
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
22
|
+
|
|
6
23
|
## 6.0.1 (2024-03-09)
|
|
7
24
|
|
|
8
25
|
### Performance Improvements
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -76,12 +76,13 @@ class Observable extends disposable.BatchDisposable {
|
|
|
76
76
|
subscribe(subscriber) {
|
|
77
77
|
if (subscriber.disposed)
|
|
78
78
|
return noopUnsubscribable;
|
|
79
|
+
const prevValue = this._lastNotifiedValue;
|
|
80
|
+
const value = this._value;
|
|
79
81
|
if (this.disposed) {
|
|
82
|
+
subscriber.next(value, prevValue);
|
|
80
83
|
subscriber.dispose();
|
|
81
84
|
return noopUnsubscribable;
|
|
82
85
|
}
|
|
83
|
-
const prevValue = this._lastNotifiedValue;
|
|
84
|
-
const value = this._value;
|
|
85
86
|
this._flush();
|
|
86
87
|
const item = { subscriber, inactive: false };
|
|
87
88
|
this._subscribers.push(item);
|
|
@@ -181,13 +182,12 @@ class Ticker extends Observable {
|
|
|
181
182
|
}
|
|
182
183
|
if (observable.disposed)
|
|
183
184
|
return noopUnobservable;
|
|
184
|
-
const subscriber = new Subscriber({
|
|
185
|
-
onNext: () => this.tick(),
|
|
186
|
-
onDispose: () => unsubscribable.unsubscribe(),
|
|
187
|
-
});
|
|
185
|
+
const subscriber = new Subscriber({ onNext: () => this.tick() });
|
|
188
186
|
const unsubscribable = observable.subscribe(subscriber);
|
|
187
|
+
const disposable$1 = new disposable.Disposable(() => unsubscribable.unsubscribe());
|
|
189
188
|
this.registerDisposable(subscriber);
|
|
190
|
-
|
|
189
|
+
this.registerDisposable(disposable$1);
|
|
190
|
+
return { unobserve: () => disposable$1.dispose() };
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
|
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) => { };
|
|
@@ -74,12 +74,13 @@ class Observable extends BatchDisposable {
|
|
|
74
74
|
subscribe(subscriber) {
|
|
75
75
|
if (subscriber.disposed)
|
|
76
76
|
return noopUnsubscribable;
|
|
77
|
+
const prevValue = this._lastNotifiedValue;
|
|
78
|
+
const value = this._value;
|
|
77
79
|
if (this.disposed) {
|
|
80
|
+
subscriber.next(value, prevValue);
|
|
78
81
|
subscriber.dispose();
|
|
79
82
|
return noopUnsubscribable;
|
|
80
83
|
}
|
|
81
|
-
const prevValue = this._lastNotifiedValue;
|
|
82
|
-
const value = this._value;
|
|
83
84
|
this._flush();
|
|
84
85
|
const item = { subscriber, inactive: false };
|
|
85
86
|
this._subscribers.push(item);
|
|
@@ -179,13 +180,12 @@ class Ticker extends Observable {
|
|
|
179
180
|
}
|
|
180
181
|
if (observable.disposed)
|
|
181
182
|
return noopUnobservable;
|
|
182
|
-
const subscriber = new Subscriber({
|
|
183
|
-
onNext: () => this.tick(),
|
|
184
|
-
onDispose: () => unsubscribable.unsubscribe(),
|
|
185
|
-
});
|
|
183
|
+
const subscriber = new Subscriber({ onNext: () => this.tick() });
|
|
186
184
|
const unsubscribable = observable.subscribe(subscriber);
|
|
185
|
+
const disposable = new Disposable(() => unsubscribable.unsubscribe());
|
|
187
186
|
this.registerDisposable(subscriber);
|
|
188
|
-
|
|
187
|
+
this.registerDisposable(disposable);
|
|
188
|
+
return { unobserve: () => disposable.dispose() };
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/observable",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
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.1",
|
|
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.1/packages/observable#readme",
|
|
14
14
|
"keywords": [
|
|
15
15
|
"observable"
|
|
16
16
|
],
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"@guanghechen/error.types": "^1.0.1",
|
|
39
39
|
"@guanghechen/observable.types": "^6.0.1"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "20a6680c86bec2fe654fb53598d6c913707eccfc"
|
|
42
42
|
}
|