{"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 * 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.\n *\n * \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 Every other second, emit the click events from the next 500ms\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} 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} An observable of arrays of buffered values.\n * @method bufferToggle\n * @owner Observable\n */\nexport function bufferToggle(this: Observable, openings: SubscribableOrPromise,\n closingSelector: (value: O) => SubscribableOrPromise): Observable {\n return higherOrder(openings, closingSelector)(this) as Observable;\n}\n"]}