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

refactor(Subscriber): update type declaration for Subscriber #597

Closed
wants to merge 1 commit into from

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Oct 25, 2015

  • Subscriber applies generic type constraint

Subscriber itself does have type constraint via generic, it actually doesn't work for values or creating new observables, like below code snippet

Rx.Observable.create((observer: Rx.Subscriber<number>) => {
    observer.next(42);
    observer.next('a');
    observer.complete();

    return () => {
        console.log('disposed');
    };
})

should be caught by compiler since type constraint of given subscriber is number, but it doesn't by Subscriber::next() does not apply type constraint for values.

type constraint is not applied for values
image

PR makes Subscriber now follows given types more explicitly let compiler allows type checking for build time.

type constraint applied after changes
image

This change also brings correct generic type checking for operators either operator passes same type or either different type like <in, out>. No functional changes are introduced, change affects only for type declaration.

@luisgabriel
Copy link
Contributor

👍

- Subscriber applies generic type constraint
@benlesh
Copy link
Member

benlesh commented Oct 27, 2015

Merged with 0329b50... thanks, as always @kwonoj!

@benlesh benlesh closed this Oct 27, 2015
@kwonoj kwonoj deleted the refactor-subscriber branch October 27, 2015 18:50
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants