This repository has been archived by the owner on Oct 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
docs(operators): add documentation for windowWhen #291
Open
hardikpthv
wants to merge
9
commits into
ReactiveX:master
Choose a base branch
from
hardikpthv:iss-127
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b63a81a
docs(operators): add documentation for windowWhen
hardikpthv a988691
fix: remove submodule
hardikpthv c72f931
Merge branch 'master' into iss-127
hardikpthv a0c0645
fix(operators): add code snippet
hardikpthv 6f0204f
Merge branch 'master' into iss-127
hardikpthv 03bf73d
Merge branch 'master' into iss-127
hardikpthv b66c39a
fix(operators): update code snippet
hardikpthv 9fc6255
Merge branch 'master' into iss-127
hardikpthv 4bca2d1
Merge branch 'master' into iss-127
hardikpthv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule rxjs-docs
deleted from
5059b4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,85 @@ | ||
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 { interval } from "rxjs/observable/interval"; | ||
import { mergeAll, windowWhen } from "rxjs/operators"; | ||
|
||
const clicks = Rx.Observable.fromEvent(document, 'click'); | ||
const result = clicks | ||
.windowWhen(() => interval(1000 + Math.random() * 4000)) | ||
.map(win => win.take(2)) // each window has at most 2 emissions | ||
.mergeAll(); // flatten the Observable-of-Observables | ||
result.subscribe(x => console.log(x)); | ||
|
||
/* | ||
Example console output | ||
[object MouseEvent] { | ||
altKey: false, | ||
AT_TARGET: 2, | ||
bubbles: true, | ||
BUBBLING_PHASE: 3, | ||
button: 0, | ||
buttons: 0, | ||
cancelable: true, | ||
cancelBubble: false, | ||
CAPTURING_PHASE: 1, | ||
clientX: 80, | ||
clientY: 70, | ||
.... //Entire object properties | ||
} | ||
*/ | ||
`, | ||
externalLink: { | ||
platform: 'JSBin', | ||
url: 'http://jsbin.com/zegowub/embed?js,console,output' | ||
} | ||
} | ||
], | ||
relatedOperators: [ | ||
'window', | ||
'windowCount', | ||
'windowTime', | ||
'windowToggle', | ||
'bufferWhen' | ||
] | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use es6 imports and pipe operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay @ashwin-sureshkumar