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

MetaStream type should allow factory to return nullish value #305

Closed
earthlyreason opened this issue Aug 8, 2021 · 2 comments
Closed

MetaStream type should allow factory to return nullish value #305

earthlyreason opened this issue Aug 8, 2021 · 2 comments

Comments

@earthlyreason
Copy link
Contributor

According to the docstring for metaStream:

If the function returns null/undefined, no further action will be taken

So shouldn't the factory type here

factory: Fn<A, Subscription<B, B>>;

allow nullish values:

    factory: Fn<A, Subscription<B, B> | null | undefined>;

Currently, usages like this

    metaStream((x: string | undefined) => x && reactive(x));

get an error like this

Argument of type '(x: string | undefined) => "" | rs.Stream<string> | undefined' is not assignable to parameter of type 'Fn<string | undefined, Subscription<string, string>>'.
  Type '"" | Stream<string> | undefined' is not assignable to type 'Subscription<string, string>'.
    Type 'undefined' is not assignable to type 'Subscription<string, string>'. [2345]
@postspectacular
Copy link
Member

You're absolutely right, @gavinpc-mindgrub! Have updated the sigs and also switched to the more general ISubscription interface as return type (even though currently everything is pretty much a subclass of Subscription only)...

@earthlyreason
Copy link
Contributor Author

Many thanks @postspectacular!

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

No branches or pull requests

2 participants