Skip to content

Commit b194d55

Browse files
volivajosepot
andauthored
docs: add description for toKeySet operator (#257)
Co-authored-by: Josep M Sobrepere <jm.sobrepere@gmail.com>
1 parent f9b6175 commit b194d55

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/utils/src/partitionByKey.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface KeyChanges<K> {
2323
* @param streamSelector Function to apply to each resulting group
2424
* @returns [1, 2]
2525
* 1. A function that accepts a key and returns the stream for the group of that key.
26-
* 2. A stream with the list of active keys
26+
* 2. A stream of KeyChanges, an object that describes what keys have been added or deleted.
2727
*/
2828
export function partitionByKey<T, K, R>(
2929
stream: Observable<T>,
@@ -39,7 +39,7 @@ export function partitionByKey<T, K, R>(
3939
* @param keySelector Function that specifies the key for each element in `stream`
4040
* @returns [1, 2]
4141
* 1. A function that accepts a key and returns the stream for the group of that key.
42-
* 2. A stream with the list of active keys
42+
* 2. A stream of KeyChanges, an object that describes what keys have been added or deleted.
4343
*/
4444
export function partitionByKey<T, K>(
4545
stream: Observable<T>,

packages/utils/src/toKeySet.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Observable, OperatorFunction } from "rxjs"
22
import { KeyChanges } from "./partitionByKey"
33

4+
/**
5+
* Operator function that maps a stream of KeyChanges into a Set that contains
6+
* the active keys.
7+
*/
48
export function toKeySet<K>(): OperatorFunction<KeyChanges<K>, Set<K>> {
59
return (source$) =>
610
new Observable<Set<K>>((observer) => {

0 commit comments

Comments
 (0)