Currently, I am utilizing bindCallback
in a way that is now considered deprecated as seen below:
const someMapping = (data) => { return { ... }};
public someCall(id) {
// Foo.someFunction is function with callbacks
return this.toObservable(Foo.someFunction, someMapping, id);
}
private toObservable(func, mappingFunction, ...args: any[]) {
return bindCallback(func, mappingFunction)(...args);
}
However, aside from the deprecation issue, there is another concern. When I manually call the someFunction
:
var callFn = function(data) {...}
var warnFn = function(data) {...}
var errFn = function(data) {...}
Foo.someFunction(id, {callback: callFn, warningHandler: warnFn, errorHandler: errFn})
The function will correctly handle success, warnings, and errors. Since I did not create these DWR callback functions myself and they cannot be changed, the existing documentation does not provide sufficient guidance.
How can I adapt this code to manage all three types of callbacks (success, warning, error) and convert them into observables? Both warnings and errors have the potential to throw an error.