fix(bindCallback): properly set context of input function #2319
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current behaviour:
Currently when input function (function that is passed as argument to
bindCallback
) is internally called, its context is set to context of underlying observable. If input function is not bound beforehand it is possible to implement:Expected behaviour
Since output function (function returned by `bindCallback) should behave identically as input function (apart from changing callback to observable) it is reasonable to assume that context of ouput function will become context of input function.
In fact this is what rxjs 4 does, as seen here:
https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/perf/operators/fromcallback.js#L41
This pr implements such behaviour.
Related
This pr does not change operator api. There is still no option to manually set context, which is possible in rxjs 4:
Please let me know if I should add such functionality in this pr, create another pr or drop context setting functionality altogether.
Have a great day!