effector / effector/effector

postFilter option in sample operator

Open
#662 2 comments 3 reactions 0 assignees View on GitHub
RFC
Dominant language
TypeScript
Stars
4.9k
Forks
280
Avg merge
2d 6h
Merged PRs (30d)
7

Description

## Proposal

Extend `sample` operator params with `postFilter` field, that would technically work the same as ordinary `filter` function, but evaluating right after `fn` does.

## Use case

```ts
/**
* Without postFilter
*/
guard({
clock: sample({
clock: chunksLoaded,
/** returns string or null */
fn: getSortingOrderFromChunks,
}),
/** passes through valid strings only */
filter: Boolean,
target: sortingUpdated,
});

/**
* With postFilter
*/
sample({
clock: chunksLoaded,
fn: getSortingOrderFromChunks,
postFilter: Boolean,
target: sortingUpdated,
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.