Skip to content

API for dispatching "resourcewillchange" events when DOM node is going to be removed #49

@matthewdunsdon

Description

@matthewdunsdon

When handle closing resources or removing a DOM node, I use code like the following in several places:

if (appNode && appNode.dispatchEvent) {
  appNode.dispatchEvent(new CustomEvent('resourcewillchange'))
}

Should address supply an API for doing this?


💡 One idea I had was to do something like...

define([ '@zambezi/address/lib/address', '@zambezi/address/lib/unregister'], function(address, unregister) {
  return function (req, res) {
    res(ok(view))

    function view(node) {
      var panelNode = createPanelNode(node)
      address('/my/app/notifications-panel').into(panelNode).get()

      node.addEventListener('app_closing', function() {
        unregister(panelNode)
        getPanelContainerNode(node).removeChild(panelNode)
      })
    }
  }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions