Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filter and filterMap types to Effect #376

Merged
merged 1 commit into from Aug 13, 2020
Merged

Conversation

sergeysova
Copy link
Sponsor Member

@sergeysova sergeysova commented Aug 13, 2020

const fx = createEffect().use(() => null)

const d = fx.filter({
  fn(a) {
    return a > 0
  },
})

d.watch(console.log)

fx(5)
fx(0)
fx(1)

https://share.effector.dev/G34PZ7qF

@sergeysova sergeysova requested a review from zerobias Aug 13, 2020
@@ -139,6 +139,8 @@ export interface Effect<Params, Done, Fail = Error> extends Unit<Params> {
pending: Store<boolean>
inFlight: Store<number>
watch(watcher: (payload: Params) => any): Subscription
filter(config: {fn(payload: Params): boolean}): Event<Params>
filterMap<T>(fn: (payload: Params) => T | undefined): Event<T>
Copy link
Member

@doasync doasync Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member

@doasync doasync Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you have skipped the first overload?

Copy link
Sponsor Member Author

@sergeysova sergeysova Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is forgotten.

@zerobias
Copy link
Member

zerobias commented Aug 13, 2020

👍

@zerobias zerobias merged commit 7b35a71 into master Aug 13, 2020
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants