-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(callback): Add Observable.fromCallback #729
Conversation
Ran into an odd situation. With the additional tests included in this PR, I get this error:
removing any one of the tests (or any test in I'm guessing it's a race condition somewhere, with the extra tests, the tests are running long enough to trigger the overflow. Changing the test to the following results in it passing though I'm not sure if it invalidates the test:
|
Ah, missed linting, fixing that now. |
import {tryCatch} from '../util/tryCatch'; | ||
import {errorObject} from '../util/errorObject'; | ||
|
||
export class CallbackObservable<T> extends Observable<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about align class name to observable, such as Observable.fromEvent
has implementation named FromEventObservable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to mimic PromiseObservable
with regards to that sort of thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, just noticed that too.
Tried to match things to what's going on in |
}; | ||
} | ||
} else { | ||
let subscription = new Subscription(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable seems could be const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Appreciate for effort, I didn't even noticed |
2a28cbe
to
c1e30fe
Compare
Hello! Any update on this? |
I am generally ok with current changes, but would like to ask @Blesh 's opinion also may have better suggestions than me. Also, testing failure you've mentioned makes this as bit blocked, since those issue need to be addressed and resolved to correctly merge this PR. |
Yep, willing to do whatever's needed to get those tests passing but I'm stumped. I can put in the fix I mentioned if you or @Blesh are ok with it (not sure if it breaks the spirit of the test). |
Just rough guess, maybe test cases observable is not unsubscribed? could possibly revise test case like below, what do you think @staltz ?
|
Sometimes async tests in However, I don't think this PR matches with what |
... ignore that, I was just confused by one of the tests. Perhaps the test just needs refactored a little for readability. |
c1e30fe
to
f253326
Compare
@Blesh Fixed, test is more specific now. |
}; | ||
} | ||
|
||
constructor(private callbackFunc: Function, private ctx, private selector, private args: any[], public scheduler: Scheduler = immediate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please give a newline for each argument? Like we do elsewhere, see e.g. https://github.com/ReactiveX/RxJS/blob/master/src/observables/IteratorObservable.ts#L61-L65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Thanks @SomeKittens for this PR. |
f253326
to
2760c50
Compare
@staltz as to the complexity of Each path is slightly unique, not sure what to target for refactor. |
2760c50
to
c81c413
Compare
(also rebased @kwonoj's test fixes into this branch) |
expect(err.message).toBe('Yikes!'); | ||
done(); | ||
}, | ||
null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null here should also be done.fail
c81c413
to
b4fa0c6
Compare
@staltz fixed missed null. |
Great |
Anything else? |
subscriber.complete(); | ||
} else { | ||
handler = (...innerArgs) => { | ||
let results; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can move let results
down to where it's being used on line 52
Disregard my comments. I never use this creation method. Frankly I think this is really a weird experience, and I dislike how it works. Every other |
This LGTM. However, I'm not sure about including it in |
@Blesh Agreed on it being weird, but that's how it works in Rx4 (and for that matter, Bluebird and the whole promise spectrum). I'm open to updating the signature to return an observable, possibly passing in the callback args. |
Sorry to continue pinging everyone, but is there anything else here that needs fixing? (or is the holdup deciding if this should be in core or not?) |
The hold up is mostly just me being too busy. :) Reviewing this now. |
Merged as of f6cebb6, with some minor lint fixes. Thanks @SomeKittens! This was a nice PR. |
It happens, especially around this time of year. Thanks! |
No description provided.