1 line
2.5 KiB
Plaintext
1 line
2.5 KiB
Plaintext
{"version":3,"file":"bufferToggle.js","sourceRoot":"","sources":["../../src/operator/bufferToggle.ts"],"names":[],"mappings":";AAEA,6BAA4C,2BAA2B,CAAC,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,sBAAwD,QAAkC,EACvD,eAAyD;IAC1F,MAAM,CAAC,2BAAW,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,IAAI,CAAoB,CAAC;AACzE,CAAC;AAHe,oBAAY,eAG3B,CAAA","sourcesContent":["\nimport { Observable, SubscribableOrPromise } from '../Observable';\nimport { bufferToggle as higherOrder } from '../operators/bufferToggle';\n\n/**\n * Buffers the source Observable values starting from an emission from\n * `openings` and ending when the output of `closingSelector` emits.\n *\n * <span class=\"informal\">Collects values from the past as an array. Starts\n * collecting only when `opening` emits, and calls the `closingSelector`\n * function to get an Observable that tells when to close the buffer.</span>\n *\n * <img src=\"./img/bufferToggle.png\" width=\"100%\">\n *\n * Buffers values from the source by opening the buffer via signals from an\n * Observable provided to `openings`, and closing and sending the buffers when\n * a Subscribable or Promise returned by the `closingSelector` function emits.\n *\n * @example <caption>Every other second, emit the click events from the next 500ms</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var openings = Rx.Observable.interval(1000);\n * var buffered = clicks.bufferToggle(openings, i =>\n * i % 2 ? Rx.Observable.interval(500) : Rx.Observable.empty()\n * );\n * buffered.subscribe(x => console.log(x));\n *\n * @see {@link buffer}\n * @see {@link bufferCount}\n * @see {@link bufferTime}\n * @see {@link bufferWhen}\n * @see {@link windowToggle}\n *\n * @param {SubscribableOrPromise<O>} openings A Subscribable or Promise of notifications to start new\n * buffers.\n * @param {function(value: O): SubscribableOrPromise} closingSelector A function that takes\n * the value emitted by the `openings` observable and returns a Subscribable or Promise,\n * which, when it emits, signals that the associated buffer should be emitted\n * and cleared.\n * @return {Observable<T[]>} An observable of arrays of buffered values.\n * @method bufferToggle\n * @owner Observable\n */\nexport function bufferToggle<T, O>(this: Observable<T>, openings: SubscribableOrPromise<O>,\n closingSelector: (value: O) => SubscribableOrPromise<any>): Observable<T[]> {\n return higherOrder(openings, closingSelector)(this) as Observable<T[]>;\n}\n"]} |