-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
iBeacon plugin support #270
Conversation
Hey Thanks for the PR.. great work. Just a question, I see you are using |
Hey, This plugin's methods were written to return Q promises, which do not seem to return if the method is wrapped in the Invoking a method with the synchronous option just returns the result of the plugin's method, which in this case is a promise, so I think that usage is alright? I'm not sure that setting
The code above would output this to the console:
The promises that the class methods return aren't really important, but that's how the author wrote it, so I just tried to match his api. I'm open to suggestions, let me know what you think of all that. |
Perfect, thanks! |
Hey @justinschuldt I just looked at the code again and noticed a problem. I'm not sure how the Delegate object is supposed to work. From the look of it I think it's not working as you expect it to do so. The methods that return observables are not making sense to me. I think a better way to implement it is to create a whole new class just for Delegate. Should be something like this: export class Delegate {
private _objectInstance: any;
constructor(){
this._objectInstance = new cordova.plugins.locationManager.Delegate();
}
didChangeAuthorizationStatus(): Observable<PluginResult> {
return new Observable<PluginResult>((observer)=>{
// bind to observer on subscribe
this._objectInstance.didChangeAuthorizationStatus = observer.next.bind(observer);
// bind to noop on unsubscribe
return () => this._objectInstance.didChangeAuthorizationStatus = () => {};
});
}
// add other events the same way
} |
@Ritzlgrmft any thoughts on my comment above ^ ? |
@ihadeed At least one important statement is missing in your proposal:
But this should be called not before all needed events are subscribed. So it would be a little bit ugly to add it to your approach. An advantage of your approach is the un-subscription of the events. But to be honest, I only subscribe to the events once. I have no need to unsubscribe. And moreover: Justin's implementation just works. |
Thanks for the feedback Markus. I wasn't sure since I don't use this plugin and to be honest I never even Just wanted to point it out to make sure that the plugin is fully Thanks again! On Jul 18, 2016 3:28 AM, "Markus Wagner" notifications@github.com wrote:
|
I didn't want to assign individual functions to the delegate properties, so I assigned functions that return observables. You can subscribe to all the events of the delegate now.
I tested all the methods on iOS and Android