Datastar-SSE

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

      morph

      Merges the fragment using Idiomorph
      <https://github.com/bigskysoftware/idiomorph>. This is the default
      merge strategy.

      * FRAGMENT_MERGEMODE_INNER

      inner

      Replaces the target’s innerHTML with the fragment.

      * FRAGMENT_MERGEMODE_OUTER

      outer

      Replaces the target’s outerHTML with the fragment.

      * FRAGMENT_MERGEMODE_PREPEND

      prepend

      Prepends the fragment to the target’s children.

      * FRAGMENT_MERGEMODE_APPEND

      append

      Appends the fragment to the target’s children.

      * FRAGMENT_MERGEMODE_BEFORE

      before

      Inserts the fragment before the target as a sibling.

      * FRAGMENT_MERGEMODE_AFTER

      after

      Inserts the fragment after the target as a sibling.

      * FRAGMENT_MERGEMODE_UPSERTATTRIBUTES

      upsertAttributes

      Merges attributes from the fragment into the target – useful for
      updating a signal.

METHODS

 headers

            ->headers();

    Returns an Array Ref of the recommended headers to sent for Datastar
    SSE responses.

            Content-Type: text/event-stream
            Cache-Control: no-cache
            Connection: keep-alive
            Keep-Alive: timeout=300, max=100000

EVENTS

    Each Datastar SSE event is implements as a class method on
    Datastar::SSE. Each method accepts, but does not require, an options
    hashref as the last parameter, the options are documented per event,
    additionally all options from HTTP::ServerEvent are supported.

      * id

      The event id. If you send this, a client will send the
      "Last-Event-Id" header when reconnecting, allowing you to send the
      events missed while offline. Newlines or null characters in the event
      id are treated as a fatal error.

      * retry

      the amount of miliseconds to wait before reconnecting if the
      connection is lost. Newlines or null characters in the retry interval
      are treated as a fatal error.

 merge_fragments

            ->merge_fragments( $html_fragment, $options_hashref );
            ->merge_fragments( $html_fragment_arrayref, $options_hashref );

    datastar-merge-fragments
    <https://data-star.dev/reference/sse_events#datastar-merge-fragments>

    Merges one or more fragments into the DOM. By default, Datastar merges
    fragments using Idiomorph
    <https://github.com/bigskysoftware/idiomorph>, which matches top level
    elements based on their ID.

  OPTIONS

      * selector

      Str

      Selects the target element of the merge process using a CSS selector.

      * use_view_transition

      Bool

      Default: 0

      Sends As: useViewTransition

      Whether to use view transitions when merging into the DOM.

      * merge_mode

      Str|MERGEMODE

      Default: FRAGMENT_MERGEMODE_MORPH

      Sends As: mergeMode



( run in 1.416 second using v1.01-cache-2.11-cpan-39bf76dae61 )