Module: "urx/src/transformers"#

Transformers change and combine streams, similar to operators. urx comes with two combinators - combineLatest and merge, and one convenience filter - duc.

Index#

Functions#

Functions#

combineLatest#

combineLatest<O1, O2>(...emitters: [Emitter<O1>, Emitter<O2>]): Emitter<[O1, O2]>

Defined in urx/src/transformers.ts:81

Creates an emitter with the latest values from all passed emitters as an array.

combineLatest acts as a Depot. Using it on stateless streams persists the last emitted value of each Emitter. Provided that all emitters have emitted at least once, subscribing to the resulting emitter will immediately receive their combined latest values.

const foo = stream<number>()
const bar = stream<number>()
subscribe(combineLatest(foo, bar), ([foo, bar]) => console.log({ foo, bar }))
publish(foo, 42)
publish(bar, 43) // { foo: 42, bar: 43 }
publish(foo, 44) // { foo: 44, bar: 43 }
publish(bar, 45) // { foo: 44, bar: 45 }

Type parameters:#

Name
O1
O2

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>]

Returns: Emitter<[O1, O2]>

combineLatest<O1, O2, O3>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>]): Emitter<[O1, O2, O3]>

Defined in urx/src/transformers.ts:82

Type parameters:#

Name
O1
O2
O3

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>]

Returns: Emitter<[O1, O2, O3]>

combineLatest<O1, O2, O3, O4>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>]): Emitter<[O1, O2, O3, O4]>

Defined in urx/src/transformers.ts:83

Type parameters:#

Name
O1
O2
O3
O4

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>]

Returns: Emitter<[O1, O2, O3, O4]>

combineLatest<O1, O2, O3>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>]): Emitter<[O1, O2, O3]>

Defined in urx/src/transformers.ts:84

Type parameters:#

Name
O1
O2
O3

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>]

Returns: Emitter<[O1, O2, O3]>

combineLatest<O1, O2, O3, O4, O5>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>]): Emitter<[O1, O2, O3, O4, O5]>

Defined in urx/src/transformers.ts:85

Type parameters:#

Name
O1
O2
O3
O4
O5

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>]

Returns: Emitter<[O1, O2, O3, O4, O5]>

combineLatest<O1, O2, O3, O4, O5, O6>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>]): Emitter<[O1, O2, O3, O4, O5, O6]>

Defined in urx/src/transformers.ts:86

Type parameters:#

Name
O1
O2
O3
O4
O5
O6

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>]

Returns: Emitter<[O1, O2, O3, O4, O5, O6]>

combineLatest<O1, O2, O3, O4, O5, O6, O7>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>]): Emitter<[O1, O2, O3, O4, O5, O6, O7]>

Defined in urx/src/transformers.ts:87

Type parameters:#

Name
O1
O2
O3
O4
O5
O6
O7

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>]

Returns: Emitter<[O1, O2, O3, O4, O5, O6, O7]>

combineLatest<O1, O2, O3, O4, O5, O6, O7, O8>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>]): Emitter<[O1, O2, O3, O4, O5, O6, O7, O8]>

Defined in urx/src/transformers.ts:88

Type parameters:#

Name
O1
O2
O3
O4
O5
O6
O7
O8

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>]

Returns: Emitter<[O1, O2, O3, O4, O5, O6, O7, O8]>

combineLatest<O1, O2, O3, O4, O5, O6, O7, O8, O9>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>, Emitter<O9>]): Emitter<[O1, O2, O3, O4, O5, O6, O7, O8, O9]>

Defined in urx/src/transformers.ts:89

Type parameters:#

Name
O1
O2
O3
O4
O5
O6
O7
O8
O9

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>, Emitter<O9>]

Returns: Emitter<[O1, O2, O3, O4, O5, O6, O7, O8, O9]>

combineLatest<O1, O2, O3, O4, O5, O6, O7, O8, O9, O10>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>, Emitter<O9>, Emitter<O10>]): Emitter<[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10]>

Defined in urx/src/transformers.ts:90

Type parameters:#

Name
O1
O2
O3
O4
O5
O6
O7
O8
O9
O10

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>, Emitter<O9>, Emitter<O10>]

Returns: Emitter<[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10]>

combineLatest<O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11>(...emitters: [Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>, Emitter<O9>, Emitter<O10>, Emitter<O11>]): Emitter<[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11]>

Defined in urx/src/transformers.ts:91

Type parameters:#

Name
O1
O2
O3
O4
O5
O6
O7
O8
O9
O10
O11

Parameters:#

NameType
...emitters[Emitter<O1>, Emitter<O2>, Emitter<O3>, Emitter<O4>, Emitter<O5>, Emitter<O6>, Emitter<O7>, Emitter<O8>, Emitter<O9>, Emitter<O10>, Emitter<O11>]

Returns: Emitter<[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, O11]>


duc#

duc<T>(source: Emitter<T>, comparator?: Comparator<T>): Emitter<T>

Defined in urx/src/transformers.ts:59

A convenience wrapper that emits only the distinct values from the passed Emitter. Wraps pipe and distinctUntilChanged.

const foo = stream<number>()
// this line...
const a = duc(foo)
// is equivalent to this
const b = pipe(distinctUntilChanged(foo))

Type parameters:#

NameDescription
Tthe type of the value emitted by the source.

Parameters:#

NameTypeDefault valueDescription
sourceEmitter<T>-The source emitter.
comparatorComparator<T>defaultComparatoroptional custom comparison function for the two values.

Returns: Emitter<T>

the resulting emitter.


merge#

merge<T>(...sources: Emitter<T>[]): Emitter<T>

Defined in urx/src/transformers.ts:25

Merges one or more emitters from the same type into a new Emitter which emits values from any of the source emitters.

const foo = stream<number>()
const bar = stream<number>()
subscribe(merge(foo, bar), (value) => console.log(value)) // 42, 43
publish(foo, 42)
publish(bar, 43)

Type parameters:#

Name
T

Parameters:#

NameType
...sourcesEmitter<T>[]

Returns: Emitter<T>