operator: matchEvent

Effect operator for matching incoming events.

Importing

import { matchEvent } from '@marblejs/core';

Type declaration

matchEvent :: (EventLike | EventCreator) -> Observable<Event> -> Observable<Event>

Example

WebSockets:

import { matchEvent } from '@marblejs/core';
import { WsEffect } from '@marblejs/websockets';
const add$: WsEffect = event$ =>
event$.pipe(
matchEvent('ADD'),
map(event => event.payload), // (typeof payload) = unknown
// ...
);

HttpServerEffect:

import { matchEvent, HttpServerEffect, ServerEvent } from '@marblejs/core';
const listening$: HttpServerEffect = event$ =>
event$.pipe(
matchEvent(ServerEvent.listening),
map(event => event.payload), // (typeof payload) = { port: number; host: string; }
// ...
);