From f70043f4757bd4be69f02c0d9ce4663ef429fa2f Mon Sep 17 00:00:00 2001 From: Mike Ryan Date: Sun, 27 Mar 2016 09:35:25 -0600 Subject: [PATCH] chore(docs): Add documentation about applySelector utility --- docs/utilities.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/utilities.md b/docs/utilities.md index 83bb41c..11e2b8a 100644 --- a/docs/utilities.md +++ b/docs/utilities.md @@ -66,3 +66,23 @@ return saga$ => saga$ .map(toPayload) .do(payload => { ... }); ``` + +#### applySelector(selector: Observable => Observable) +Applies a selector function to the _state_ part of a saga iteration, returning +a new saga iteration composed of the action and the selected piece of state + +__Params__ +* `selector` __Observable => Observable__ Selector function to apply to the state + +_Returns_ `Observable>` + +```ts +function selectTodos() { + return (state$: Observable<{ todos: string[] }>) => state$ + .map(s => s.todos) + .distinctUntilChanged(); +} + +return saga$ => saga$ + .let(applySelector(selectTodos)) +```