I want to cast an any to a method signature on TypeScript.
I am using RxJs and a cordova's plugin that has an event. This event has an "any" signature, so when i bind it with "bindCallback", i cannot put my parameteres.
The following code works, but is working without observable pattern:
this.map.on((<any>window).plugin.google.maps.event.CAMERA_CHANGE, () => {
try {
console.log('it works!!');
} catch(err) {
console.log(err);
}
I think with observable pattern would to be something like this:
let eventAsObservable = Rx.Observable.bindCallback(this.map.on);
let result = eventAsObservable((<any>window).plugin.google.maps.event.CAMERA_CHANGE);
result.subscribe(x => console.log('don't work --> ' + JSON.stringify(x)));
My problem is that "eventAsObservable" don't accept parameters. I think it's because "this.map.on" is marked as any.
So, would be great if i can cast "any" to a method that accepts a numeric or string parameter signature.
How can i solved it?
Thanks a lot
Changin this
let eventAsObservable = Rx.Observable.bindCallback(this.map.on);
To this
let eventAsObservable = Rx.Observable.bindCallback(<(a: number) => any>this.map.on);
Works for me