evg_observable 1.2.34 → 1.3.35
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/README.md +15 -13
- package/package.json +3 -3
- package/src/outLib/Observable.d.ts +3 -2
- package/src/outLib/Observable.js +9 -0
- package/src/outLib/Types.d.ts +3 -0
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
[](https://socket.dev/npm/package/evg_observable)
|
|
1
2
|
<h1 align=center style="color: saddlebrown">
|
|
2
3
|
EVG Observable
|
|
3
4
|
</h1>
|
|
@@ -300,20 +301,21 @@ observable$.next('SOME DATA');
|
|
|
300
301
|
|
|
301
302
|
### Observable
|
|
302
303
|
|
|
303
|
-
| method
|
|
304
|
-
|
|
305
|
-
| `.subscribe(listener)`
|
|
304
|
+
| method | will return | description |
|
|
305
|
+
|:---------------------------| :--- | :--- |
|
|
306
|
+
| `.subscribe(listener)` | subscriber | subscribe listener to observable |
|
|
306
307
|
| `.unSubscribe(subscriber)` | void | unsubscribe listener from observable |
|
|
307
|
-
| `.unsubscribeAll()`
|
|
308
|
-
| `.next(value)`
|
|
309
|
-
| `.
|
|
310
|
-
| `.
|
|
311
|
-
| `.
|
|
312
|
-
| `.
|
|
313
|
-
| `.
|
|
314
|
-
| `.
|
|
315
|
-
| `.
|
|
316
|
-
| `.
|
|
308
|
+
| `.unsubscribeAll()` | void | unsubscribe all listeners from the current observable |
|
|
309
|
+
| `.next(value)` | void | emit data to listeners |
|
|
310
|
+
| `.stream(value[])` | void | pass data to listeners in parts of the array |
|
|
311
|
+
| `.getValue()` | value | will return the last value sent, or the value that was set during initialization |
|
|
312
|
+
| `.size()` | number | will return the current number of subscribers |
|
|
313
|
+
| `.disable()` | void | disable emission |
|
|
314
|
+
| `.enable()` | void | enable emission |
|
|
315
|
+
| `.isEnable` | boolean | read-only field that shows the state of the observer |
|
|
316
|
+
| `.destroy()` | void | unsubscribe all listeners from the current observable and destroy it |
|
|
317
|
+
| `.isDestroyed` | boolean | read-only field that shows the kill state of the observer |
|
|
318
|
+
| `.pipe()` | pipe condition object | returns an object with which you can customize the subscriber's behavior |
|
|
317
319
|
|
|
318
320
|
### Observable`.pipe()`
|
|
319
321
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "evg_observable",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.3.35",
|
|
4
|
+
"description": "Alternative fast and light library version - observable.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"test": "test"
|
|
7
7
|
},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/BarushevEA/light-observable-ts#readme",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"typescript": "^4.9.
|
|
24
|
+
"typescript": "^4.9.5",
|
|
25
25
|
"@testdeck/mocha": "^0.3.3",
|
|
26
26
|
"@types/chai": "^4.3.4",
|
|
27
27
|
"chai": "^4.3.7",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICallback, IErrorCallback, IListener, IMarkedForUnsubscribe, IObserver, ISetup, ISubscribe, ISubscribeObject, ISubscriptionLike } from "./Types";
|
|
1
|
+
import { ICallback, IErrorCallback, IListener, IMarkedForUnsubscribe, IObserver, ISetup, IStream, ISubscribe, ISubscribeObject, ISubscriptionLike } from "./Types";
|
|
2
2
|
export declare class SubscribeObject<T> implements ISubscribeObject<T>, IMarkedForUnsubscribe {
|
|
3
3
|
isMarkedForUnsubscribe: boolean;
|
|
4
4
|
protected observable: IObserver<T> | undefined;
|
|
@@ -29,7 +29,7 @@ export declare class SubscribeObject<T> implements ISubscribeObject<T>, IMarkedF
|
|
|
29
29
|
get order(): number;
|
|
30
30
|
set order(value: number);
|
|
31
31
|
}
|
|
32
|
-
export declare class Observable<T> implements IObserver<T> {
|
|
32
|
+
export declare class Observable<T> implements IObserver<T>, IStream<T> {
|
|
33
33
|
private value;
|
|
34
34
|
protected listeners: ISubscribeObject<T>[];
|
|
35
35
|
private _isEnable;
|
|
@@ -41,6 +41,7 @@ export declare class Observable<T> implements IObserver<T> {
|
|
|
41
41
|
enable(): void;
|
|
42
42
|
get isEnable(): boolean;
|
|
43
43
|
next(value: T): void;
|
|
44
|
+
stream(values: T[]): void;
|
|
44
45
|
private handleListenersForUnsubscribe;
|
|
45
46
|
unSubscribe(listener: ISubscriptionLike<T>): void;
|
|
46
47
|
destroy(): void;
|
package/src/outLib/Observable.js
CHANGED
|
@@ -168,6 +168,15 @@ class Observable {
|
|
|
168
168
|
this.isNextProcess = false;
|
|
169
169
|
this.listenersForUnsubscribe.length && this.handleListenersForUnsubscribe();
|
|
170
170
|
}
|
|
171
|
+
stream(values) {
|
|
172
|
+
if (this._isDestroyed)
|
|
173
|
+
return;
|
|
174
|
+
if (!this._isEnable)
|
|
175
|
+
return;
|
|
176
|
+
for (let i = 0; i < values.length; i++) {
|
|
177
|
+
this.next(values[i]);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
171
180
|
handleListenersForUnsubscribe() {
|
|
172
181
|
const length = this.listenersForUnsubscribe.length;
|
|
173
182
|
for (let i = 0; i < length; i++) {
|
package/src/outLib/Types.d.ts
CHANGED