Created
February 25, 2018 21:16
-
-
Save MikeRyanDev/3939d6ad0729bc3f8db1b4fb692033cf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
groupBy( | |
/** | |
* Select groups by their `bookId` | |
*/ | |
action => action.bookId, | |
/** | |
* Map each action to the `bookId` for convenience | |
*/ | |
action => action.bookId, | |
/** | |
* The duration selector lets us create an observable that | |
* instructs `groupBy` when to dispose of a group. It will | |
* be disposed when either the returned observable emits a | |
* a value or completes | |
*/ | |
bookId$ => bookId$.pipe( | |
/** | |
* The `timeoutWith` operator lets you time out an observable | |
* after a set amount of time and then falls back to the | |
* provided observable. | |
* | |
* Here we want to timeout after 15s and then fall back to | |
* no behavior | |
*/ | |
timeoutWith(15000, Observable.empty()), | |
/** | |
* When telling `groupBy` when to end we don't want it | |
* to dispose of the group when the group has a new action | |
* so we simply have it ignore all actions, instead waiting | |
* to dispose the group when it times out | |
*/ | |
ignoreElements(), | |
), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment