From 17e6b068b4b58d1a595de832779f2d19123f27ae Mon Sep 17 00:00:00 2001 From: sumitarora Date: Sun, 29 Oct 2017 18:58:06 -0400 Subject: [PATCH] docs(operator-docs): Added MergeAll operator documentation --- src/operator-docs/combination/mergeAll.ts | 77 ++++++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/src/operator-docs/combination/mergeAll.ts b/src/operator-docs/combination/mergeAll.ts index d0be8ca6..ea96d3fc 100644 --- a/src/operator-docs/combination/mergeAll.ts +++ b/src/operator-docs/combination/mergeAll.ts @@ -1,6 +1,77 @@ -import { OperatorDoc } from '../operator.model'; +import { OperatorDoc } from "../operator.model"; export const mergeAll: OperatorDoc = { - 'name': 'mergeAll', - 'operatorType': 'combination' + name: "mergeAll", + operatorType: "combination", + signature: "public mergeAll(concurrent: number): Observable", + parameters: [ + { + name: "concurrent", + type: "number", + attribute: "optional, default: Number.POSITIVE_INFINITY", + description: `Maximum number of input Observables being subscribed to concurrently.` + } + ], + marbleUrl: "http://reactivex.io/rxjs/img/mergeAll.png", + shortDescription: { + description: `Converts a higher-order Observable into a first-order Observable which concurrently + delivers all values that are emitted on the inner Observables`, + extras: [ + { + type: "Tip", + text: "Flattens an Observable-of-Observables." + } + ] + }, + walkthrough: { + description: ` +

MergeAll subscribes to an Observable that emits Observables, + also known as a higher-order Observable. Each time it observes one of these emitted + inner Observables, it subscribes to that and delivers all the values from the inner + Observable on the output Observable. The output Observable only completes once all inner + Observables have completed. Any error delivered by a inner Observable will be immediately + emitted on the output Observable.

+ ` + }, + examples: [ + { + name: + "Spawn a new interval Observable for each click event, and blend their outputs as one Observable", + code: ` + const clicks = Rx.Observable.fromEvent(document, 'click'); + const higherOrder = clicks.map((ev) => Rx.Observable.interval(1000)); + const firstOrder = higherOrder.mergeAll(); + firstOrder.subscribe(x => console.log(x)); + `, + externalLink: { + platform: "JSBin", + url: "http://jsbin.com/lebidefocu/1/edit?js,output" + } + }, + { + name: + "Count from 0 to 9 every second for each click, but only allow 2 concurrent timers", + code: ` + const clicks = Rx.Observable.fromEvent(document, 'click'); + const higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10)); + const firstOrder = higherOrder.mergeAll(2); + firstOrder.subscribe(x => console.log(x)); + `, + externalLink: { + platform: "JSBin", + url: "http://jsbin.com/kokezoribu/edit?js,output" + } + } + ], + relatedOperators: [ + "combineAll", + "concatAll", + "exhaust", + "merge", + "mergeMap", + "mergeMapTo", + "mergeScan", + "switch", + "zipAll" + ] };