Skip to main

ofEvent

ofEvent

Creates a source which will emit only the given event. This means that if the given event is a Push event then the returned source will emit the value followed by an End event.

See Also

Signature - source.ts#L836

function ofEvent(event: Throw | End): Source<never>

Parameters

ParameterTypeDescription
event
Throw | End

The Throw or End event to emit.

Example Usage

import { ofEvent, Throw, pipe, subscribe } from '@microstream/core';

const source = ofEvent(Throw(new Error('ERROR!1!!1!')));
pipe(source, subscribe(console.log));
// End(Error(...))

See Also

function ofEvent<T>(event: Event<T>): Source<T>

Parameters

ParameterTypeDescription
event
Event<T>

The event to emit.

Example Usage

import { ofEvent, Push, pipe, subscribe } from '@microstream/core';

const source = ofEvent(Push(123));
pipe(source, subscribe(console.log));
// Push(123)
// End