Skip to content
Dan Stocker edited this page Jun 1, 2019 · 2 revisions

Usage: createFilter<V>(cb: (value: V, tag?: Tag) => boolean)

Module: flowcode-fp

Type: Filter<V>

Input ports:

  • d_val: V

Output ports:

  • b_d_val: V
  • d_val: V
  • ev_err: string

Filters input values according to a filter callback. Bounces input, and emits stringified error when callback throws.

import {connect} from "flowcode";
import {createFilter} from "flowcode-fp";
const filter = createFilter(next => next > 5);
connect(filter.o.d_val, console.log);
filter.i.d_val(3); // doesn't log
filter.i.d_val(5); // doesn't log
filter.i.d_val(8); // logs: 8

Clone this wiki locally