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

Update type of Event.filter #170

merged 1 commit into from Aug 8, 2019


Copy link

abliarsar commented Aug 8, 2019

Refine type of payload if filter got a predicate function as a callback

import { createEvent } from 'effector'

const event = createEvent<string | number>()

const isString = (value: any): value is string => typeof value === 'string'
const isNumber = (value: any): value is number => typeof value === 'number'

const str = event.filter({fn: isString}) // Event<string>
const num = event.filter({fn: isNumber}) // Event<number> => value.slice()) // OK now => value.toFixed(2)) // OK now

This comment has been minimized.

Copy link

now bot commented Aug 8, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch:


This comment has been minimized.

Copy link

zerobias commented Aug 8, 2019

Wow, I didn’t think it was possible 😄

@zerobias zerobias merged commit 7a42b23 into zerobias:master Aug 8, 2019
3 checks passed
3 checks passed
WIP Ready for review
now Deployment has completed
semaphoreci The build passed on Semaphore.
@abliarsar abliarsar deleted the abliarsar:fix-filter-type branch Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.