VulpesOS/assets/webapps/system.gaiamobile.org/js/activity_handler.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

37 lines
868 B
JavaScript

/* global LazyLoader, Import */
'use strict';
(function(exports) {
/**
* A global activity handler which dispatches mozSetMessageHandler events.
*/
function ActivityHandler() {}
ActivityHandler.prototype = {
/**
* Starts listening for activities.
*/
start: function() {
window.navigator.mozSetMessageHandler('activity',
this.handleActivity.bind(this));
return LazyLoader.load(['js/import.js']).then(() => {
this.import = new Import();
return Promise.resolve(this.import.start());
});
},
/**
* Handles activity requests.
*/
handleActivity: function(activity) {
var name = activity.source.name;
window.dispatchEvent(new CustomEvent('activity-' + name, {
detail: activity
}));
}
};
exports.ActivityHandler = ActivityHandler;
}(window));