transmit Method
Overload 1
Transmits values from the current emitter to one or more other emitters, states, or subjects. It enables the propagation of data or events across multiple sources, effectively creating a network of interconnected reactive sources
@param ...outputs: (EmitterOrSubject<T> | EmitterOrSubject<void>)[]
One or more emitters, states, or subjects that will receive the transmitted values from this emitter
@returns this
The instance of the emitter, allowing for method chaining
API
transmit(...outputs: (EmitterOrSubject<T> | EmitterOrSubject<void>)[]): this;
Example
import {Subject} from 'rxjs';
import {emitter, state} from '@bitfiber/rx';
const receiver1 = emitter<number>();
const receiver2 = state<number>(0);
const receiver3 = new Subject<number>();
const source = emitter<number>(e => e
// Transmits every emitted value to all reactive sources for further processing or handling
.transmit(receiver1, receiver2, receiver3));
Overload 2
Transmits values from the current emitter to a state. By using a reducer function, the emitted values can be transformed or customized to match the expected format of the state
@param output: AbstractState<O>
A state that will receive the transmitted values from this emitter
@param reducer: (value: T, state: O) => O
A function that converts or transforms the emitted value from this emitter type to the type expected
by the state
@returns this
The instance of the emitter, allowing for method chaining
API
transmit<O>(output: AbstractState<O>, reducer: (value: T, state: O) => O): this;
Example
import {emitter, state} from '@bitfiber/rx';
const receiver = state<number>(0);
const source = emitter<string>(e => e
// Transmits every emitted value to the state for further processing or handling.
// By using a reducer function, the emitted values can be transformed to match the expected
// format of the state
.transmit(receiver, (value, state) => state + Number(value)));
Overload 3
Transmits values from the current emitter to another emitter or subject. By using a reducer function, the emitted values can be transformed or customized to match the expected format of the target emitter or subject
@param output: EmitterOrSubject<O>
An emitter or subject that will receive the transmitted values from this emitter
@param reducer: (value: T) => O
A function that converts or transforms the emitted value from the current emitter’s type to the type
expected by the receiving emitter or subject
@returns this
The instance of the emitter, allowing for method chaining
API
transmit<O>(output: EmitterOrSubject<O>, reducer: (value: T) => O): this;
Example
import {emitter} from '@bitfiber/rx';
const receiver = emitter<number>();
const source = emitter<string>(e => e
// Transmits every emitted value to another emitter for further processing or handling.
// By using a reducer function, the emitted values can be transformed to match the expected
// format of the receiving emitter
.transmit(receiver, value => Number(value)));