The Bus.Handle to Observe.
Optional
suffix: PropertyKeyAn optional suffix
property for the handle
.
A prototype property decorator.
Observe the 'io.github.sgrud.example'
stream:
import { type Bus, Observe } from '@sgrud/bus';
import { type Observable } from 'rxjs';
export class Observer {
@Observe('io.github.sgrud.example')
public readonly stream!: Observable<Bus.Value<unknown>>;
}
Observer.prototype.stream.subscribe(console.log);
Observe the 'io.github.sgrud.example'
stream:
import { type Bus, Observe } from '@sgrud/bus';
import { type Observable } from 'rxjs';
export class Observer {
@Observe('io.github.sgrud', 'suffix')
public readonly stream!: Observable<Bus.Value<unknown>>;
public constructor(
public readonly suffix: string
) { }
}
const observer = new Observer('example');
observer.stream.subscribe(console.log);
Generated using TypeDoc
Prototype property decorator factory. Applying this decorator replaces the decorated property with a getter returning an Observable stream which Observes all values originating from the supplied
handle
. Depending on the value of thesuffix
parameter, this Observable stream is either assigned directly to the prototype using the suppliedhandle
, or, if a truthy value is supplied for thesuffix
parameter, this value is assumed to reference another property of the class containing this decorated property. The first truthy value assigned to thissuffix
property on an instance of the class containing this Stream decorator will then be used to suffix the suppliedhandle
which is to be Observed and assign the resulting Observable stream to the decorated instance property.This decorator is more or less the opposite of the Publish decorator, while both rely on the BusHandler to fulfill contracts.