UNPKG

@wscsports/blaze-rtn-gam-ads

Version:
40 lines 1.24 kB
import { RegisterGlobalEvents } from "./utils/RegisterGlobalEvents"; export class BlazeGlobalDelegateHelper { static registerDelegate(delegate) { BlazeGlobalDelegateHelper.onGAMAdEvent(delegate?.onGAMAdEvent); BlazeGlobalDelegateHelper.onGAMAdError(delegate?.onGAMAdError); } static onGAMAdEvent(callback) { const eventName = 'BlazeGAM.onAdEvent'; if (callback) { RegisterGlobalEvents.createEventSubscription(eventName, data => { try { const eventType = data['eventType']; callback({ eventType }); } catch (e) { console.error('onGAMAdEvent', e); } }); } else { RegisterGlobalEvents.cancelEventSubscription(eventName); } } static onGAMAdError(callback) { const eventName = 'BlazeGAM.onAdError'; if (callback) { RegisterGlobalEvents.createEventSubscription(eventName, data => { try { const errorMessage = data['errorMessage']; callback(errorMessage); } catch (e) { console.error('onGAMAdError', e); } }); } else { RegisterGlobalEvents.cancelEventSubscription(eventName); } } } //# sourceMappingURL=BlazeGAMDelegate.js.map