The Bus.Handle to Stream.
Optional
suffix: PropertyKeyAn optional suffix
property for the handle
.
A prototype property decorator.
Stream 'io.github.sgrud.example'
:
import { type Bus, Stream } from '@sgrud/bus';
export class Streamer {
@Stream('io.github.sgrud.example')
public readonly stream!: Bus<unknown, unknown>;
}
Streamer.prototype.stream.next('value');
Streamer.prototype.stream.complete();
Streamer.prototype.stream.subscribe({
next: console.log
});
Stream 'io.github.sgrud.example'
:
import { type Bus, Stream } from '@sgrud/bus';
export class Streamer {
@Stream('io.github.sgrud', 'suffix')
public readonly stream!: Bus<unknown>;
public constructor(
public readonly suffix: string
) { }
}
const streamer = new Streamer('example');
streamer.stream.next('value');
streamer.stream.complete();
streamer.stream.subscribe({
next: console.log
});
Generated using TypeDoc
Prototype property decorator factory. Applying this decorator replaces the decorated property with a getter returning a Bus, thereby allowing to duplex Stream values designated by the supplied
handle
. Depending on the value of thesuffix
parameter, this Bus 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
upon construction of the Bus, which is assigned to the decorated instance property.Through these two different modes of operation, a Bus can be assigned statically to the prototype of the class containing the decorated property, or this assignment can be deferred until an instance of the class containing the decorated property is constructed and a truthy value is assigned to its
suffix
property.