Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

docs(operators): add documentation for windowWhen #291

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion rxjs-docs
Submodule rxjs-docs deleted from 5059b4
85 changes: 83 additions & 2 deletions src/operator-docs/transformation/windowWhen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,87 @@
import { OperatorDoc } from '../operator.model';

export const windowWhen: OperatorDoc = {
'name': 'windowWhen',
'operatorType': 'transformation'
name: 'windowWhen',
operatorType: 'transformation',
signature: `public windowWhen(closingSelector: function(): Observable): Observable`,
parameters: [
{
name: 'closingSelector',
type: 'function(): Observable',
attribute: '',
description: `
A function that takes no arguments and returns an Observable that signals
(on either 'next' or 'complete') when to close the previous window and start a new one.`
}
],
marbleUrl: 'http://reactivex.io/rxjs/img/windowWhen.png',
shortDescription: {
description: `
Branch out the source Observable values as a nested Observable using a factory function of
closing Observables to determine when to start a new window.`,
extras: [
{
type: 'Tip',
text: `
It's like <a href="#/operators/bufferWhen" class="markdown-code">bufferWhen</a>,
but emits a nested Observable instead of an array.
`
}
]
},
walkthrough: {
description: `
Returns an Observable that emits windows of items it collects from the source Observable. The output Observable
emits connected, non-overlapping windows. It emits the current window and opens a new one whenever the Observable
produced by the specified <span class="markdown-code">closingSelector</span> function emits an item. The first
window is opened immediately when subscribing to the output Observable.`
},
examples: [
{
name:
'Emit only the first two clicks events in every window of [1-5] random seconds',
code: `
import { fromEvent } from 'rxjs/observable/fromEvent';
import { interval } from 'rxjs/observable/interval';
import { mergeAll, tap, windowWhen } from 'rxjs/operators';

const clicks = fromEvent(document, 'click');
const result = clicks.pipe(
windowWhen(() => interval(3000)),
tap(() => console.log('Window Initated!'))
);
result.pipe(mergeAll()).subscribe(x => console.log(x));

/*
Example console output
'Window Initated!'
'Window Initated!'
'Window Initated!'
'Window Initated!' //clicked on document
[object MouseEvent] {
altKey: false,
AT_TARGET: 2,
bubbles: true,
BUBBLING_PHASE: 3,
button: 0,
buttons: 0,
cancelable: true,
cancelBubble: false,
.... //Entire object properties
}
*/
`,
externalLink: {
platform: 'JSBin',
url: 'http://jsbin.com/zegowub/embed?js,console,output'
}
}
],
relatedOperators: [
'window',
'windowCount',
'windowTime',
'windowToggle',
'bufferWhen'
]
};