windowCount

signature: windowCount(windowSize: number, startWindowEvery: number): Observable

Observable of values from source, emitted each time provided count is fulfilled.

Examples

Example 1: Start new window every x items emitted

( jsBin | jsFiddle )

//emit every 1s
const source = Rx.Observable.interval(1000);
const example = source
    //start new window every 4 emitted values
    .windowCount(4)
    .do(() => console.log('NEW WINDOW!'))

const subscribeTwo = example 
  //window emits nested observable
  .mergeAll()
/*
  output:
  "NEW WINDOW!"
  0
  1
  2
  3
  "NEW WINDOW!"
  4
  5
  6
  7 
*/
  .subscribe(val => console.log(val));

Additional Resources


:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/operator/windowCount.ts

results matching ""

    No results matching ""