From fc149339533ba60de009f5ca8b9e85ef306c089d Mon Sep 17 00:00:00 2001 From: Martin Hunt Date: Fri, 6 Mar 2015 00:46:05 -0800 Subject: [PATCH] Release 2.2.0 - export the native window API so native plugins can detect when games are listening for events on the window object ``` import devkit.native.Window as nativeWindow; nativeWindow.on('newListener', function (type, cb) { console.log("new native listener for", type); }); window.addEventListener("devicemotion", function () { ... }); ``` --- src/clientapi/native/Window.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/clientapi/native/Window.js b/src/clientapi/native/Window.js index 7d14409..b124a5a 100644 --- a/src/clientapi/native/Window.js +++ b/src/clientapi/native/Window.js @@ -14,24 +14,22 @@ * along with the Game Closure SDK. If not, see . */ -"use import"; - import lib.PubSub; -var _evts = new lib.PubSub(); +module.exports = new lib.PubSub(); window.open = window.open || window.setLocation; window.addEventListener = function (evtName, cb, isBubble) { - _evts.subscribe(evtName, window, cb); + module.exports.on(evtName, cb); } window.removeEventListener = function (evtName, cb, isBubble) { - _evts.unsubscribe(evtName, window, cb); + module.exports.removeListener(evtName, cb); } window.__fireEvent = function (name, evt) { - if (!evt) { evt = {}; } - evt.type = name; - _evts.publish(name, evt); + if (!evt) { evt = {}; } + evt.type = name; + module.exports.publish(name, evt); }