rxjs-to-timed-emissions
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

RxJS toTimedEmissions

Convert an array of anything to a stream of timed RxJS emissions.

Install

  yarn add rxjs-to-timed-emissions

Usage

import toTimedEmissions$$ from "rxjs-to-timed-emissions";

const INPUT = Array.from({ length: 10 }, (v, i) => ({ i }));
const MAPPER = (v: any) => v.i * 2;
const OUTPUT$ = toTimedEmissions$$(INPUT, v => v.i * 10, MAPPER);
const onNext = jest.fn();
let output = [] as any[];

OUTPUT$.subscribe(
  (v: any) => {
    onNext(v);
    output.push(v);
  },
  () => {},
  () => {
    expect(onNext.mock.calls.length).toEqual(10);
    expect(output).toEqual(INPUT.map(MAPPER));
    done();
  }
);

API

Signature :

function toTimedEmissions$$<T extends any, V extends any>(
  inputArray: T[],
  getTimestampFromValue?: ((v: T, i: number) => number),
  mapValue?: ((v: T, i: number) => V | T)
): Observable<T | V>;

Readme

Keywords

none

Package Sidebar

Install

npm i rxjs-to-timed-emissions

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

4.35 kB

Total Files

7

Last publish

Collaborators

  • rakannimer