Skip to content

Commit

Permalink
add event listeners after onLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
opus1269 committed Sep 21, 2017
1 parent 92a2752 commit 62e8c73
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions app/scripts/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,28 @@
return false;
}

// listen for extension install or update
chrome.runtime.onInstalled.addListener(_onInstalled);
/**
* Event: called when document and resources are loaded
* @private
* @memberOf Background
*/
function _onLoad() {
// listen for extension install or update
chrome.runtime.onInstalled.addListener(_onInstalled);

// listen for Chrome starting
chrome.runtime.onStartup.addListener(_onStartup);
// listen for Chrome starting
chrome.runtime.onStartup.addListener(_onStartup);

// listen for click on the icon
chrome.browserAction.onClicked.addListener(_onIconClicked);
// listen for click on the icon
chrome.browserAction.onClicked.addListener(_onIconClicked);

// listen for changes to the stored data
addEventListener('storage', _onStorageChanged, false);
// listen for changes to the stored data
addEventListener('storage', _onStorageChanged, false);

// listen for chrome messages
Chrome.Msg.listen(_onChromeMessage);
// listen for chrome messages
Chrome.Msg.listen(_onChromeMessage);
}

// listen for document and resources loaded
window.addEventListener('load', _onLoad);
})();

0 comments on commit 62e8c73

Please sign in to comment.