marcs-observable
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "marcs-observable", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "a typed version of marc grabanski's observablish-values supporting frontend masters website realtime operations", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -55,24 +55,36 @@ # marcs-observable | ||
#### ObservableFactory.create(initialValue: any, ...args: any[]): IObservable | ||
```ts | ||
ObservableFactory.create(initialValue: any, ...args: any[]): IObservable | ||
``` | ||
Creates a new observable. If the initial value is a function, the observable becomes a computed observable. Any extra arguments will be passed to the function. | ||
#### observable.subscribe(handler: (current: any, previous: any) => void): () => void | ||
```ts | ||
observable.subscribe(handler: (current: any, previous: any) => void): () => void | ||
``` | ||
Subscribes to the observable. The handler function is called whenever the observable's value changes. The function returns an unsubscribe function. | ||
#### observable.publish(): void | ||
```ts | ||
observable.value: any | ||
``` | ||
Gets or sets the value of the observable. If the observable is a computed observable, setting the value will not affect the computed function. | ||
```ts | ||
observable.publish(): void | ||
``` | ||
Publishes changes to the observable. This is usually not called directly, but is used internally when the observable's value changes. | ||
#### observable.compute(): void | ||
```ts | ||
observable.compute(): void | ||
``` | ||
Recomputes the value of a computed observable. This is usually not called directly, but is used internally when a dependency of the computed observable changes. | ||
#### observable.value: any | ||
```ts | ||
Observable.delay(ms: number) | ||
``` | ||
Gets or sets the value of the observable. If the observable is a computed observable, setting the value will not affect the computed function. | ||
#### Observable.delay(ms: number) | ||
Returns a promise that resolves after a delay of ms milliseconds. This is used for handling asynchronous computations in computed observables. | ||
@@ -79,0 +91,0 @@ |
15690
102