ssi.nostr.onPrefEnabledChanged

Fire when the preference value of selfsovereignindividual.nostr.enabled changed

Syntax

browser.ssi.nostr.onPrefEnabledChanged.addListener(listener)
browser.ssi.nostr.onPrefEnabledChanged.removeListener(listener)
browser.ssi.nostr.onPrefEnabledChanged.hasListener(listener)

Events have three functions:

addListener(listener) Adds a listener to this event.

removeListener(listener) Stop listening to this event. The listener argument is the listener to remove.

hasListener(listener) Check whether listener is registered for this event. Returns true if it is listening, false otherwise.

addListener syntax

Parameters

None.

Examples

Listening the value of selfsovereignindividual.nostr.enabled changed in about:config, update and notify it.

const onPrefEnabledChangedCallback = async () => {
  // Get the new value.
  const prefs = await browser.ssi.getPrefs()
  // Update store value
  store.prefs.enabled = prefs.enabled

  // Send the message to the contents
  const tabs = await browser.tabs.query()
  for (const tab of tabs) {
    browser.tabs
      .sendMessage(tab.id, {
        action: "providerChanged",
        args: { enabled: store.prefs.enabled },
      })
  }
}
browser.ssi.nostr.onPrefEnabledChanged.addListener(onPrefEnabledChangedCallback)

Note

This documentation is derived from ssi.nostr.json in gecko-dev-for-ssi.