@cycle/xstream-adapter
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -59,3 +59,3 @@ "use strict"; | ||
return (typeof stream.addListener === 'function' && | ||
typeof stream.imitate === 'function'); | ||
typeof stream.shamefullySendNext === 'function'); | ||
}, | ||
@@ -62,0 +62,0 @@ streamSubscribe: function (stream, observer) { |
{ | ||
"name": "@cycle/xstream-adapter", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Cycle.js xstream Stream Adapter", | ||
@@ -34,3 +34,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@cycle/base": "^2.0.1", | ||
"@cycle/base": "^2.1.1", | ||
"assert": "^1.3.0", | ||
@@ -54,6 +54,6 @@ "babel-preset-es2015": "^6.6.0", | ||
"validate-commit-msg": "^2.4.0", | ||
"xstream": "2.x.x" | ||
"xstream": "4.x.x" | ||
}, | ||
"peerDependencies": { | ||
"xstream": "2.x.x" | ||
"xstream": "4.x.x" | ||
}, | ||
@@ -60,0 +60,0 @@ "config": { |
@@ -71,3 +71,3 @@ import { | ||
typeof stream.addListener === 'function' && | ||
typeof stream.imitate === 'function'); | ||
typeof stream.shamefullySendNext === 'function'); | ||
}, | ||
@@ -74,0 +74,0 @@ |
@@ -44,3 +44,5 @@ // Generated by typings | ||
} | ||
function Cycle<Sources, Sinks>(main: (sources: Sources) => Sinks, drivers: DriversDefinition, options: CycleOptions): CycleExecution<Sources, Sinks>; | ||
function Cycle<Sources, Sinks>(main: (sources: Sources) => Sinks, drivers: { | ||
[name: string]: Function; | ||
}, options: CycleOptions): CycleExecution<Sources, Sinks>; | ||
export default Cycle; | ||
@@ -47,0 +49,0 @@ } |
@@ -9,2 +9,3 @@ // Generated by typings | ||
} | ||
export const emptyListener: InternalListener<any>; | ||
export interface InternalProducer<T> { | ||
@@ -15,2 +16,4 @@ _start: (listener: InternalListener<T>) => void; | ||
export interface Operator<T, R> extends InternalProducer<R>, InternalListener<T> { | ||
type: string; | ||
ins: Stream<T>; | ||
_start: (out: Stream<R>) => void; | ||
@@ -21,3 +24,2 @@ _stop: () => void; | ||
_c: () => void; | ||
type: string; | ||
} | ||
@@ -48,9 +50,2 @@ export interface Producer<T> { | ||
} | ||
export interface CombineInstanceSignature<T> { | ||
<T2, R>(project: (t1: T, t2: T2) => R, stream2: Stream<T2>): Stream<R>; | ||
<T2, T3, R>(project: (t1: T, t2: T2, t3: T3) => R, stream2: Stream<T2>, stream3: Stream<T3>): Stream<R>; | ||
<T2, T3, T4, R>(project: (t1: T, t2: T2, t3: T3, t4: T4) => R, stream2: Stream<T2>, stream3: Stream<T3>, stream4: Stream<T4>): Stream<R>; | ||
<T2, T3, T4, T5, R>(project: (t1: T, t2: T2, t3: T3, t4: T4, t5: T5) => R, stream2: Stream<T2>, stream3: Stream<T3>, stream4: Stream<T4>, stream5: Stream<T5>): Stream<R>; | ||
<R>(project: (...args: Array<any>) => R, ...streams: Array<Stream<any>>): Stream<R>; | ||
} | ||
export class CombineListener<T> implements InternalListener<T> { | ||
@@ -116,7 +111,8 @@ private i; | ||
export class DebugOperator<T> implements Operator<T, T> { | ||
spy: (t: T) => any; | ||
ins: Stream<T>; | ||
type: string; | ||
private out; | ||
constructor(spy: (t: T) => any, ins: Stream<T>); | ||
private s; | ||
private l; | ||
constructor(arg: string | ((t: T) => any), ins: Stream<T>); | ||
_start(out: Stream<T>): void; | ||
@@ -167,15 +163,2 @@ _stop(): void; | ||
} | ||
export class FlattenConcOperator<T> implements Operator<Stream<T>, T> { | ||
ins: Stream<Stream<T>>; | ||
type: string; | ||
private active; | ||
private out; | ||
constructor(ins: Stream<Stream<T>>); | ||
_start(out: Stream<T>): void; | ||
_stop(): void; | ||
less(): void; | ||
_n(s: Stream<T>): void; | ||
_e(err: any): void; | ||
_c(): void; | ||
} | ||
export class FlattenOperator<T> implements Operator<Stream<T>, T> { | ||
@@ -223,24 +206,12 @@ ins: Stream<Stream<T>>; | ||
} | ||
export class MapFlattenConcOperator<T> implements InternalProducer<T>, InternalListener<T> { | ||
mapOp: MapOperator<T, Stream<T>>; | ||
export class MapFlattenOperator<T, R> implements Operator<T, R> { | ||
mapOp: MapOperator<T, Stream<R>>; | ||
type: string; | ||
private active; | ||
private out; | ||
constructor(mapOp: MapOperator<T, Stream<T>>); | ||
_start(out: Stream<T>): void; | ||
_stop(): void; | ||
less(): void; | ||
_n(v: T): void; | ||
_e(err: any): void; | ||
_c(): void; | ||
} | ||
export class MapFlattenOperator<T> implements InternalProducer<T>, InternalListener<T> { | ||
mapOp: MapOperator<T, Stream<T>>; | ||
type: string; | ||
inner: Stream<T>; | ||
ins: Stream<T>; | ||
inner: Stream<R>; | ||
private il; | ||
private open; | ||
private out; | ||
constructor(mapOp: MapOperator<T, Stream<T>>); | ||
_start(out: Stream<T>): void; | ||
constructor(mapOp: MapOperator<T, Stream<R>>); | ||
_start(out: Stream<R>): void; | ||
_stop(): void; | ||
@@ -270,14 +241,2 @@ less(): void; | ||
} | ||
export class MapToOperator<T, R> implements Operator<T, R> { | ||
val: R; | ||
ins: Stream<T>; | ||
type: string; | ||
private out; | ||
constructor(val: R, ins: Stream<T>); | ||
_start(out: Stream<R>): void; | ||
_stop(): void; | ||
_n(t: T): void; | ||
_e(err: any): void; | ||
_c(): void; | ||
} | ||
export class ReplaceErrorOperator<T> implements Operator<T, T> { | ||
@@ -321,3 +280,3 @@ fn: (err: any) => Stream<T>; | ||
private _prod; | ||
constructor(producer: InternalProducer<T>); | ||
constructor(producer?: InternalProducer<T>); | ||
_n(t: T): void; | ||
@@ -341,2 +300,3 @@ _e(err: any): void; | ||
_remove(il: InternalListener<T>): void; | ||
private ctor(); | ||
/** | ||
@@ -361,2 +321,10 @@ * Creates a new Stream given a Producer. | ||
/** | ||
* Creates a new MimicStream, which can `imitate` another Stream. Only a | ||
* MimicStream has the `imitate()` method. | ||
* | ||
* @factory true | ||
* @return {MimicStream} | ||
*/ | ||
static createMimic<T>(): MimicStream<T>; | ||
/** | ||
* Creates a Stream that does nothing when started. It never emits any event. | ||
@@ -530,2 +498,3 @@ * | ||
static combine: CombineFactorySignature; | ||
protected _map<U>(project: (t: T) => U): Stream<U> | MemoryStream<U>; | ||
/** | ||
@@ -639,3 +608,4 @@ * Transforms each event from the input Stream through a `project` function, | ||
* Prepends the given `initial` value to the sequence of events emitted by the | ||
* input stream. | ||
* input stream. The returned stream is a MemoryStream, which means it is | ||
* already `remember()`'d. | ||
* | ||
@@ -651,5 +621,5 @@ * Marble diagram: | ||
* @param initial The value or event to prepend. | ||
* @return {Stream} | ||
* @return {MemoryStream} | ||
*/ | ||
startWith(initial: T): Stream<T>; | ||
startWith(initial: T): MemoryStream<T>; | ||
/** | ||
@@ -680,3 +650,4 @@ * Uses another stream to determine when to complete the current stream. | ||
* the entire execution of the input stream, allowing you to accumulate them | ||
* together. It's essentially like `Array.prototype.reduce`. | ||
* together. It's essentially like `Array.prototype.reduce`. The returned | ||
* stream is a MemoryStream, which means it is already `remember()`'d. | ||
* | ||
@@ -702,5 +673,5 @@ * The output stream starts by emitting the `seed` which you give as argument. | ||
* @param seed The initial accumulated value, of type `R`. | ||
* @return {Stream} | ||
* @return {MemoryStream} | ||
*/ | ||
fold<R>(accumulate: (acc: R, t: T) => R, seed: R): Stream<R>; | ||
fold<R>(accumulate: (acc: R, t: T) => R, seed: R): MemoryStream<R>; | ||
/** | ||
@@ -724,3 +695,3 @@ * Replaces an error with another stream. | ||
* @param {Function} replace A function of type `(err) => Stream` that takes | ||
* the error that occured on the input stream or on the previous replacement | ||
* the error that occurred on the input stream or on the previous replacement | ||
* stream and returns a new stream. The output stream will imitate the stream | ||
@@ -758,78 +729,2 @@ * that this function returns. | ||
/** | ||
* Flattens a "stream of streams", handling multiple concurrent nested streams | ||
* simultaneously. | ||
* | ||
* If the input stream is a stream that emits streams, then this operator will | ||
* return an output stream which is a flat stream: emits regular events. The | ||
* flattening happens concurrently. It works like this: when the input stream | ||
* emits a nested stream, *flattenConcurrently* will start imitating that | ||
* nested one. When the next nested stream is emitted on the input stream, | ||
* *flattenConcurrently* will also imitate that new one, but will continue to | ||
* imitate the previous nested streams as well. | ||
* | ||
* Marble diagram: | ||
* | ||
* ```text | ||
* --+--------+--------------- | ||
* \ \ | ||
* \ ----1----2---3-- | ||
* --a--b----c----d-------- | ||
* flattenConcurrently | ||
* -----a--b----c-1--d-2---3-- | ||
* ``` | ||
* | ||
* @return {Stream} | ||
*/ | ||
flattenConcurrently<R>(): T; | ||
/** | ||
* Blends two streams together, emitting events from both. | ||
* | ||
* *merge* takes an `other` stream and returns an output stream that imitates | ||
* both the input stream and the `other` stream. | ||
* | ||
* Marble diagram: | ||
* | ||
* ```text | ||
* --1----2-----3--------4--- | ||
* ----a-----b----c---d------ | ||
* merge | ||
* --1-a--2--b--3-c---d--4--- | ||
* ``` | ||
* | ||
* @param {Stream} other Another stream to merge together with the input | ||
* stream. | ||
* @return {Stream} | ||
*/ | ||
merge(other: Stream<T>): Stream<T>; | ||
/** | ||
* Combines multiple streams with the input stream to return a stream whose | ||
* events are calculated from the latest events of each of its input streams. | ||
* | ||
* *combine* remembers the most recent event from each of the input streams. | ||
* When any of the input streams emits an event, that event together with all | ||
* the other saved events are combined in the `project` function which should | ||
* return a value. That value will be emitted on the output stream. It's | ||
* essentially a way of mixing the events from multiple streams according to a | ||
* formula. | ||
* | ||
* Marble diagram: | ||
* | ||
* ```text | ||
* --1----2-----3--------4--- | ||
* ----a-----b-----c--d------ | ||
* combine((x,y) => x+y) | ||
* ----1a-2a-2b-3b-3c-3d-4d-- | ||
* ``` | ||
* | ||
* @param {Function} project A function of type `(x: T1, y: T2) => R` or | ||
* similar that takes the most recent events `x` and `y` from the input | ||
* streams and returns a value. The output stream will emit that value. The | ||
* number of arguments for this function should match the number of input | ||
* streams. | ||
* @param {Stream} other Another stream to combine together with the input | ||
* stream. There may be more of these arguments. | ||
* @return {Stream} | ||
*/ | ||
combine: CombineInstanceSignature<T>; | ||
/** | ||
* Passes the input stream to a custom operator, to produce an output stream. | ||
@@ -855,12 +750,2 @@ * | ||
/** | ||
* Changes this current stream to imitate the `other` given stream. | ||
* | ||
* The *imitate* method returns nothing. Instead, it changes the behavior of | ||
* the current stream, making it re-emit whatever events are emitted by the | ||
* given `other` stream. | ||
* @param {Stream} other The stream to imitate on the current one. | ||
*/ | ||
imitate(other: Stream<T>): void; | ||
/** | ||
* Returns an output stream that identically imitates the input stream, but | ||
@@ -886,7 +771,8 @@ * also runs a `spy` function fo each event, to help you debug your app. | ||
* | ||
* @param {function} spy A function that takes an event as argument, and | ||
* returns nothing. | ||
* @param {function} labelOrSpy A string to use as the label when printing | ||
* debug information on the console, or a 'spy' function that takes an event | ||
* as argument, and does not need to return anything. | ||
* @return {Stream} | ||
*/ | ||
debug(spy?: (t: T) => void): Stream<T>; | ||
debug(labelOrSpy?: string | ((t: T) => void)): Stream<T>; | ||
/** | ||
@@ -923,2 +809,21 @@ * Forces the Stream to emit the given value to its listeners. | ||
} | ||
export class MimicStream<T> extends Stream<T> { | ||
private _target; | ||
constructor(); | ||
_add(il: InternalListener<T>): void; | ||
_remove(il: InternalListener<T>): void; | ||
/** | ||
* This method exists only on a MimicStream, which is created through | ||
* `xs.createMimic()`. `imitate` changes this current MimicStream to imitate | ||
* the `other` given stream. | ||
* | ||
* The *imitate* method returns nothing. Instead, it changes the behavior of | ||
* the current stream, making it re-emit whatever events are emitted by the | ||
* given `other` stream. | ||
* | ||
* @param {Stream} other The stream to imitate on the current one. Must not be | ||
* a MemoryStream. | ||
*/ | ||
imitate(other: Stream<T>): void; | ||
} | ||
export class MemoryStream<T> extends Stream<T> { | ||
@@ -930,2 +835,9 @@ private _v; | ||
_add(il: InternalListener<T>): void; | ||
_x(): void; | ||
map<U>(project: (t: T) => U): MemoryStream<U>; | ||
mapTo<U>(projectedValue: U): MemoryStream<U>; | ||
take(amount: number): MemoryStream<T>; | ||
endWhen(other: Stream<any>): MemoryStream<T>; | ||
replaceError(replace: (err: any) => Stream<T>): MemoryStream<T>; | ||
debug(labelOrSpy?: string | ((t: T) => void)): MemoryStream<T>; | ||
} | ||
@@ -942,5 +854,5 @@ export default Stream; | ||
declare module 'xstream' { | ||
import { Stream, MemoryStream, Listener, Producer, Operator } from '~xstream/core'; | ||
export { Stream, MemoryStream, Listener, Producer, Operator }; | ||
import { Stream, MemoryStream, MimicStream, Listener, Producer, Operator } from '~xstream/core'; | ||
export { Stream, MemoryStream, MimicStream, Listener, Producer, Operator }; | ||
export default Stream; | ||
} |
@@ -44,3 +44,5 @@ // Generated by typings | ||
} | ||
function Cycle<Sources, Sinks>(main: (sources: Sources) => Sinks, drivers: DriversDefinition, options: CycleOptions): CycleExecution<Sources, Sinks>; | ||
function Cycle<Sources, Sinks>(main: (sources: Sources) => Sinks, drivers: { | ||
[name: string]: Function; | ||
}, options: CycleOptions): CycleExecution<Sources, Sinks>; | ||
export default Cycle; | ||
@@ -47,0 +49,0 @@ } |
@@ -9,2 +9,3 @@ // Generated by typings | ||
} | ||
export const emptyListener: InternalListener<any>; | ||
export interface InternalProducer<T> { | ||
@@ -15,2 +16,4 @@ _start: (listener: InternalListener<T>) => void; | ||
export interface Operator<T, R> extends InternalProducer<R>, InternalListener<T> { | ||
type: string; | ||
ins: Stream<T>; | ||
_start: (out: Stream<R>) => void; | ||
@@ -21,3 +24,2 @@ _stop: () => void; | ||
_c: () => void; | ||
type: string; | ||
} | ||
@@ -48,9 +50,2 @@ export interface Producer<T> { | ||
} | ||
export interface CombineInstanceSignature<T> { | ||
<T2, R>(project: (t1: T, t2: T2) => R, stream2: Stream<T2>): Stream<R>; | ||
<T2, T3, R>(project: (t1: T, t2: T2, t3: T3) => R, stream2: Stream<T2>, stream3: Stream<T3>): Stream<R>; | ||
<T2, T3, T4, R>(project: (t1: T, t2: T2, t3: T3, t4: T4) => R, stream2: Stream<T2>, stream3: Stream<T3>, stream4: Stream<T4>): Stream<R>; | ||
<T2, T3, T4, T5, R>(project: (t1: T, t2: T2, t3: T3, t4: T4, t5: T5) => R, stream2: Stream<T2>, stream3: Stream<T3>, stream4: Stream<T4>, stream5: Stream<T5>): Stream<R>; | ||
<R>(project: (...args: Array<any>) => R, ...streams: Array<Stream<any>>): Stream<R>; | ||
} | ||
export class CombineListener<T> implements InternalListener<T> { | ||
@@ -116,7 +111,8 @@ private i; | ||
export class DebugOperator<T> implements Operator<T, T> { | ||
spy: (t: T) => any; | ||
ins: Stream<T>; | ||
type: string; | ||
private out; | ||
constructor(spy: (t: T) => any, ins: Stream<T>); | ||
private s; | ||
private l; | ||
constructor(arg: string | ((t: T) => any), ins: Stream<T>); | ||
_start(out: Stream<T>): void; | ||
@@ -167,15 +163,2 @@ _stop(): void; | ||
} | ||
export class FlattenConcOperator<T> implements Operator<Stream<T>, T> { | ||
ins: Stream<Stream<T>>; | ||
type: string; | ||
private active; | ||
private out; | ||
constructor(ins: Stream<Stream<T>>); | ||
_start(out: Stream<T>): void; | ||
_stop(): void; | ||
less(): void; | ||
_n(s: Stream<T>): void; | ||
_e(err: any): void; | ||
_c(): void; | ||
} | ||
export class FlattenOperator<T> implements Operator<Stream<T>, T> { | ||
@@ -223,24 +206,12 @@ ins: Stream<Stream<T>>; | ||
} | ||
export class MapFlattenConcOperator<T> implements InternalProducer<T>, InternalListener<T> { | ||
mapOp: MapOperator<T, Stream<T>>; | ||
export class MapFlattenOperator<T, R> implements Operator<T, R> { | ||
mapOp: MapOperator<T, Stream<R>>; | ||
type: string; | ||
private active; | ||
private out; | ||
constructor(mapOp: MapOperator<T, Stream<T>>); | ||
_start(out: Stream<T>): void; | ||
_stop(): void; | ||
less(): void; | ||
_n(v: T): void; | ||
_e(err: any): void; | ||
_c(): void; | ||
} | ||
export class MapFlattenOperator<T> implements InternalProducer<T>, InternalListener<T> { | ||
mapOp: MapOperator<T, Stream<T>>; | ||
type: string; | ||
inner: Stream<T>; | ||
ins: Stream<T>; | ||
inner: Stream<R>; | ||
private il; | ||
private open; | ||
private out; | ||
constructor(mapOp: MapOperator<T, Stream<T>>); | ||
_start(out: Stream<T>): void; | ||
constructor(mapOp: MapOperator<T, Stream<R>>); | ||
_start(out: Stream<R>): void; | ||
_stop(): void; | ||
@@ -270,14 +241,2 @@ less(): void; | ||
} | ||
export class MapToOperator<T, R> implements Operator<T, R> { | ||
val: R; | ||
ins: Stream<T>; | ||
type: string; | ||
private out; | ||
constructor(val: R, ins: Stream<T>); | ||
_start(out: Stream<R>): void; | ||
_stop(): void; | ||
_n(t: T): void; | ||
_e(err: any): void; | ||
_c(): void; | ||
} | ||
export class ReplaceErrorOperator<T> implements Operator<T, T> { | ||
@@ -321,3 +280,3 @@ fn: (err: any) => Stream<T>; | ||
private _prod; | ||
constructor(producer: InternalProducer<T>); | ||
constructor(producer?: InternalProducer<T>); | ||
_n(t: T): void; | ||
@@ -341,2 +300,3 @@ _e(err: any): void; | ||
_remove(il: InternalListener<T>): void; | ||
private ctor(); | ||
/** | ||
@@ -361,2 +321,10 @@ * Creates a new Stream given a Producer. | ||
/** | ||
* Creates a new MimicStream, which can `imitate` another Stream. Only a | ||
* MimicStream has the `imitate()` method. | ||
* | ||
* @factory true | ||
* @return {MimicStream} | ||
*/ | ||
static createMimic<T>(): MimicStream<T>; | ||
/** | ||
* Creates a Stream that does nothing when started. It never emits any event. | ||
@@ -530,2 +498,3 @@ * | ||
static combine: CombineFactorySignature; | ||
protected _map<U>(project: (t: T) => U): Stream<U> | MemoryStream<U>; | ||
/** | ||
@@ -639,3 +608,4 @@ * Transforms each event from the input Stream through a `project` function, | ||
* Prepends the given `initial` value to the sequence of events emitted by the | ||
* input stream. | ||
* input stream. The returned stream is a MemoryStream, which means it is | ||
* already `remember()`'d. | ||
* | ||
@@ -651,5 +621,5 @@ * Marble diagram: | ||
* @param initial The value or event to prepend. | ||
* @return {Stream} | ||
* @return {MemoryStream} | ||
*/ | ||
startWith(initial: T): Stream<T>; | ||
startWith(initial: T): MemoryStream<T>; | ||
/** | ||
@@ -680,3 +650,4 @@ * Uses another stream to determine when to complete the current stream. | ||
* the entire execution of the input stream, allowing you to accumulate them | ||
* together. It's essentially like `Array.prototype.reduce`. | ||
* together. It's essentially like `Array.prototype.reduce`. The returned | ||
* stream is a MemoryStream, which means it is already `remember()`'d. | ||
* | ||
@@ -702,5 +673,5 @@ * The output stream starts by emitting the `seed` which you give as argument. | ||
* @param seed The initial accumulated value, of type `R`. | ||
* @return {Stream} | ||
* @return {MemoryStream} | ||
*/ | ||
fold<R>(accumulate: (acc: R, t: T) => R, seed: R): Stream<R>; | ||
fold<R>(accumulate: (acc: R, t: T) => R, seed: R): MemoryStream<R>; | ||
/** | ||
@@ -724,3 +695,3 @@ * Replaces an error with another stream. | ||
* @param {Function} replace A function of type `(err) => Stream` that takes | ||
* the error that occured on the input stream or on the previous replacement | ||
* the error that occurred on the input stream or on the previous replacement | ||
* stream and returns a new stream. The output stream will imitate the stream | ||
@@ -758,78 +729,2 @@ * that this function returns. | ||
/** | ||
* Flattens a "stream of streams", handling multiple concurrent nested streams | ||
* simultaneously. | ||
* | ||
* If the input stream is a stream that emits streams, then this operator will | ||
* return an output stream which is a flat stream: emits regular events. The | ||
* flattening happens concurrently. It works like this: when the input stream | ||
* emits a nested stream, *flattenConcurrently* will start imitating that | ||
* nested one. When the next nested stream is emitted on the input stream, | ||
* *flattenConcurrently* will also imitate that new one, but will continue to | ||
* imitate the previous nested streams as well. | ||
* | ||
* Marble diagram: | ||
* | ||
* ```text | ||
* --+--------+--------------- | ||
* \ \ | ||
* \ ----1----2---3-- | ||
* --a--b----c----d-------- | ||
* flattenConcurrently | ||
* -----a--b----c-1--d-2---3-- | ||
* ``` | ||
* | ||
* @return {Stream} | ||
*/ | ||
flattenConcurrently<R>(): T; | ||
/** | ||
* Blends two streams together, emitting events from both. | ||
* | ||
* *merge* takes an `other` stream and returns an output stream that imitates | ||
* both the input stream and the `other` stream. | ||
* | ||
* Marble diagram: | ||
* | ||
* ```text | ||
* --1----2-----3--------4--- | ||
* ----a-----b----c---d------ | ||
* merge | ||
* --1-a--2--b--3-c---d--4--- | ||
* ``` | ||
* | ||
* @param {Stream} other Another stream to merge together with the input | ||
* stream. | ||
* @return {Stream} | ||
*/ | ||
merge(other: Stream<T>): Stream<T>; | ||
/** | ||
* Combines multiple streams with the input stream to return a stream whose | ||
* events are calculated from the latest events of each of its input streams. | ||
* | ||
* *combine* remembers the most recent event from each of the input streams. | ||
* When any of the input streams emits an event, that event together with all | ||
* the other saved events are combined in the `project` function which should | ||
* return a value. That value will be emitted on the output stream. It's | ||
* essentially a way of mixing the events from multiple streams according to a | ||
* formula. | ||
* | ||
* Marble diagram: | ||
* | ||
* ```text | ||
* --1----2-----3--------4--- | ||
* ----a-----b-----c--d------ | ||
* combine((x,y) => x+y) | ||
* ----1a-2a-2b-3b-3c-3d-4d-- | ||
* ``` | ||
* | ||
* @param {Function} project A function of type `(x: T1, y: T2) => R` or | ||
* similar that takes the most recent events `x` and `y` from the input | ||
* streams and returns a value. The output stream will emit that value. The | ||
* number of arguments for this function should match the number of input | ||
* streams. | ||
* @param {Stream} other Another stream to combine together with the input | ||
* stream. There may be more of these arguments. | ||
* @return {Stream} | ||
*/ | ||
combine: CombineInstanceSignature<T>; | ||
/** | ||
* Passes the input stream to a custom operator, to produce an output stream. | ||
@@ -855,12 +750,2 @@ * | ||
/** | ||
* Changes this current stream to imitate the `other` given stream. | ||
* | ||
* The *imitate* method returns nothing. Instead, it changes the behavior of | ||
* the current stream, making it re-emit whatever events are emitted by the | ||
* given `other` stream. | ||
* @param {Stream} other The stream to imitate on the current one. | ||
*/ | ||
imitate(other: Stream<T>): void; | ||
/** | ||
* Returns an output stream that identically imitates the input stream, but | ||
@@ -886,7 +771,8 @@ * also runs a `spy` function fo each event, to help you debug your app. | ||
* | ||
* @param {function} spy A function that takes an event as argument, and | ||
* returns nothing. | ||
* @param {function} labelOrSpy A string to use as the label when printing | ||
* debug information on the console, or a 'spy' function that takes an event | ||
* as argument, and does not need to return anything. | ||
* @return {Stream} | ||
*/ | ||
debug(spy?: (t: T) => void): Stream<T>; | ||
debug(labelOrSpy?: string | ((t: T) => void)): Stream<T>; | ||
/** | ||
@@ -923,2 +809,21 @@ * Forces the Stream to emit the given value to its listeners. | ||
} | ||
export class MimicStream<T> extends Stream<T> { | ||
private _target; | ||
constructor(); | ||
_add(il: InternalListener<T>): void; | ||
_remove(il: InternalListener<T>): void; | ||
/** | ||
* This method exists only on a MimicStream, which is created through | ||
* `xs.createMimic()`. `imitate` changes this current MimicStream to imitate | ||
* the `other` given stream. | ||
* | ||
* The *imitate* method returns nothing. Instead, it changes the behavior of | ||
* the current stream, making it re-emit whatever events are emitted by the | ||
* given `other` stream. | ||
* | ||
* @param {Stream} other The stream to imitate on the current one. Must not be | ||
* a MemoryStream. | ||
*/ | ||
imitate(other: Stream<T>): void; | ||
} | ||
export class MemoryStream<T> extends Stream<T> { | ||
@@ -930,2 +835,9 @@ private _v; | ||
_add(il: InternalListener<T>): void; | ||
_x(): void; | ||
map<U>(project: (t: T) => U): MemoryStream<U>; | ||
mapTo<U>(projectedValue: U): MemoryStream<U>; | ||
take(amount: number): MemoryStream<T>; | ||
endWhen(other: Stream<any>): MemoryStream<T>; | ||
replaceError(replace: (err: any) => Stream<T>): MemoryStream<T>; | ||
debug(labelOrSpy?: string | ((t: T) => void)): MemoryStream<T>; | ||
} | ||
@@ -942,5 +854,5 @@ export default Stream; | ||
declare module 'xstream' { | ||
import { Stream, MemoryStream, Listener, Producer, Operator } from '~xstream/core'; | ||
export { Stream, MemoryStream, Listener, Producer, Operator }; | ||
import { Stream, MemoryStream, MimicStream, Listener, Producer, Operator } from '~xstream/core'; | ||
export { Stream, MemoryStream, MimicStream, Listener, Producer, Operator }; | ||
export default Stream; | ||
} |
Sorry, the diff of this file is not supported yet
398806
9423