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: bindCallback and bindNodeCallback are based on the same… #5781

Merged

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Sep 30, 2020

… code

  • Add bindCallbackInternals, a base implementation for both creation methods
  • Add a missing test to bindNodeCallback to catch an issue where the initial call to the provided function was not scheduled.
  • Updates comments

This work effectively just copies and pastes the work from #5780 into a new function called bindCallbackInternals, and alters it a bit to account for the differences in the call patterns. Then it adds the use of subscribeOn to the scheduled code path, because bindCallback had a test that caught something that the tests for bindNodeCallback did not. Also adds that test for bindNodeCallback.

… code

- Add `bindCallbackInternals`, a base implementation for both creation methods
- Add a missing test to `bindNodeCallback` to catch an issue where the initial call to the provided function was not scheduled.
- Updates comments
@benlesh benlesh requested a review from cartant September 30, 2020 00:49
Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

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

Looks okay to me. Quite a few anys - and the Function type is also less than ideal - but those could be addressed in a separate PR. They're in the existing code, rather than introduced in this refactor, so ... 🤷‍♂️

@@ -255,98 +252,10 @@ export function bindNodeCallback(callbackFunc: Function, scheduler?: SchedulerLi
* deliver.
* @name bindNodeCallback
*/
export function bindNodeCallback<T>(
export function bindNodeCallback(
callbackFunc: Function,
Copy link
Collaborator

@cartant cartant Sep 30, 2020

Choose a reason for hiding this comment

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

issue: Not related to the refactor, but can we get rid of the Function usage while we're here? It's a completely useless type. IIRC, it's something like { name: string }. (I think I'll write a lint rule, now, to ban it.) (...args: any[]) => any would be better. Maybe we should have an internal type for an arbitrary function?

I can see that the bindCallback and bindNodeCallback implementation also make liberal use of any instead of an arbitrary function type. They should be fixed up, too, IMO. Maybe in another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I think it's just there from "way back when" TBH. I was pretty new to TypeScript whenever that was written.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave it for another PR though.

@benlesh benlesh merged commit 2c2fc8e into ReactiveX:master Sep 30, 2020
@jakovljevic-mladen jakovljevic-mladen mentioned this pull request Jul 21, 2022
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.

2 participants