postFilter option in sample operator
Open
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
Assessment
This issue has not been assessed yet.