phoenix_live_view
    Preparing search index...

    Function createHook

    • Creates a hook instance for the given element and callbacks.

      Parameters

      • el: HTMLElement

        The element to associate with the hook.

      • callbacks: Hook

        The list of hook callbacks, such as mounted, updated, destroyed, etc.

        Note: createHook must be called from the connectedCallback lifecycle which is triggered after the element has been added to the DOM. If you try to call createHook from the constructor, an error will be logged.

        Furthermore, you can only start using the hook's APIs after the mounted callback of the hook has been called. If you try to call them earlier, an error will be logged.

      Returns ViewHook

      Returns the Hook instance for the custom element.

      class MyComponent extends HTMLElement {
      connectedCallback(){
      let onLiveViewMounted = () => this.hook.pushEvent(...))
      this.hook = createHook(this, {mounted: onLiveViewMounted})
      }
      }