SDK Events
The SDK will dispatch events to alart an application about changes. It’s also possible for applications to use this to make custom events.
- id.init - Triggered when the SDK is ready to be used.
- auth.authResponseChange - Triggered login and post register. Returns 1 auth argument.
- dialog.show - Triggered when a sdk menu is visible.
- dialog.hide - Triggered when a sdk menu is hidden.
- dialog.resize - Triggered when a menu needs to resize. Returns 3 arguments, width, height, and overflow.
<script type="text/javascript">
window.idAsyncInit = function() {
ID.Event.subscribe('auth.authResponseChange', function(auth) {
console.log(auth);
});
ID.Event.subscribe('id.init', function() {
alert('Y8 Account SDK initialized!');
});
ID.init({
// Initialization options
});
}
</script>
Functions
- subscribers() - return list of subscribers
- subscribe(name, callback) - Start listening
- unsubscribe(name, callback) - Stop listening
- monitor(name, callback) - If you know, please tell us
- clear(name) - Deletes name from subscribers
- fire(name) - Trigger an event
Custom Events
var eventCb = function(value) {
// Do something when the event is fired
}
ID.Event.subscribe('awesome.game.custom.event', eventCb);
var score = 500;
ID.Event.fire('awesome.game.custom.event', score)