Broadcasting events in Firefox OS

I am wondering if there is a way for a Firefox OS application to broadcast the event to all other applications and for interested applications to connect to that event and trigger the appropriate action.

A use case I mean: the Camera application broadcasts a "captured image" event, and another application intercepts this event and takes some action on the new image that was taken (for example, uploading it to the server).

+3


source to share


2 answers


Currently, the web API in Firefox does not exist to broadcast events to all open and / or interested applications.

For your specific application notification use case, when the camera takes a new photo, the best way is to open DeviceStorage for "pictures" and listen for "change" events.

Documentation for this:

https://developer.mozilla.org/en-US/docs/Web/API/DeviceStorage



There are alternatives, but they are more limited in functionality and available in fewer editions and contexts:

Note. For each example here, your application must be working for it to work. There is no mechanism for waking up the application when a certain action or event occurs. Web Activity is the closest API for loading applications on specific events. The timer API is intended for non-specific application loading.

+2


source


From this article [1]:

Application authors can create an application that will handle one or more actions. This means that the application will be called by another application to perform certain actions defined by this activity. For example, let's pretend we want to create a photo manager. It can be used by another application to select a photo. As an activity handler, our application will become part of another application workflow.



[1] https://developer.mozilla.org/en-US/docs/Web/API/Web_Activities

0


source







All Articles