Deprecated
Usage
This is a variable or event handle.
Examples
Listen for all messages
jQuery(document).on('nebula_sw_message', function(e, message){ console.log('Message received via Nebula event:', message); });
Listen for a message with an object key of "demo"
jQuery(document).on('nebula_sw_message', function(e, message){ if ( message.demo ){ console.log('Message received via Nebula event:', message.demo); } });
Additional Notes
This is useful for syncing data/information between tabs without needing localstorage. Like closing a notification in one tab closes it in all tabs, or incrementing a counter on all tabs (like an ecommerce cart).
Note: the message is not sent to the same tab/window (client) that triggered it.
This event will trigger anytime the service worker receives a message, so you may need to check to make sure you are acting on the correct one.
To post a message to the service worker, use navigator.serviceWorker.controller.postMessage(data)
, or the more convenient Nebula alias: nebulaPostMessage
Deprecated in favor of Workbox Window. Use workbox.messageSW()[code] after it has been activated (Listen for [code]nebula_workbox_active
on the document).