Liking cljdoc? Tell your friends :D

starfederation.datastar.clojure.adapter.common

Namespace containing the shared code for each adapter.

It contains helpers for working with [[OutputStreams]] and assembling SSE sending function using several strategies and managing exceptions in the adapters.

The main concept here is what we call "write profiles". A write profile is a map of 3 keys:

With these 3 keys we can control buffering aspects of our SSE connection and compression functionality.

Here is an example profile which uses gzip and temporary buffers to concatenate SSE event text:

(def gzip-profile
  {wrap-output-stream (fn [^OutputStream os] (-> os ->gzip-os ->os-writer))
   content-encoding gzip-content-encoding
   write! (->write-with-temp-buffer!)})

The wrap-output-stream function will use a [[GZIPOutputStream]] and an [[OutputStreamWriter]] constructed with the ->gzip-os and ->os-writer helpers.

To go with this we use a write! function constructed with ->write-with-temp-buffer!.

If we wanted specific buffer sizes we could do:

(def gzip-profile
  {wrap-output-stream (fn[^OutputStream os]
                        (-> os
                            (->gzip-os 1024)
                            ->os-writer))
   content-encoding gzip-content-encoding
   write! (->write-with-temp-buffer! 4096)})

The output stream wrapping helpers are:

The write function helper to go with them are:

See the rest of the docstrings for more details.

Namespace containing the shared code for each adapter.

It contains helpers for working with [[OutputStreams]] and assembling SSE
sending function using several strategies and managing exceptions in the
adapters.

The main concept here is what we call "write profiles". A write profile is
a map of 3 keys:
- [[wrap-output-stream]]
- [[write!]]
- [[content-encoding]]

With these 3 keys we can control buffering aspects of our SSE connection and
compression functionality.

Here is an example profile which uses gzip and temporary buffers to
concatenate SSE event text:

```clojure
(def gzip-profile
  {wrap-output-stream (fn [^OutputStream os] (-> os ->gzip-os ->os-writer))
   content-encoding gzip-content-encoding
   write! (->write-with-temp-buffer!)})
```

The `wrap-output-stream` function will use a [[GZIPOutputStream]] and an
[[OutputStreamWriter]] constructed with the [[->gzip-os]] and [[->os-writer]]
helpers.

To go with this we use a `write!` function constructed with
[[->write-with-temp-buffer!]].

If we wanted specific buffer sizes we could do:

```clojure
(def gzip-profile
  {wrap-output-stream (fn[^OutputStream os]
                        (-> os
                            (->gzip-os 1024)
                            ->os-writer))
   content-encoding gzip-content-encoding
   write! (->write-with-temp-buffer! 4096)})
```

The output stream wrapping helpers are:
- [[->gzip-os]]
- [[->os-writer]]
- [[->buffered-writer]]

The write function helper to go with them are:
- [[->write-with-temp-buffer!]]
- [[write-to-buffered-writer!]]

See the rest of the docstrings for more details.
raw docstring

starfederation.datastar.clojure.adapter.test

Utilities providing a test SSEGenerator and a mock ->sse-response function.

Utilities providing a test SSEGenerator and a mock `->sse-response`
function.
raw docstring

starfederation.datastar.clojure.api

Public api for the Datastar SDK.

The main api consists several functions that operate on SSE generators, see:

These function take options map whose keys are:

To help manage SSE generators's underlying connection there is:

Helper to extract datastar specific data from ring requests:

Some common utilities for HTTP are also provided:

Some scripts are provided:

Public api for the Datastar SDK.

The main api consists several functions that operate on SSE generators, see:
- [[patch-elements!]]
- [[patch-elements-seq!]]
- [[remove-element!]]
- [[patch-signals!]]
- [[execute-script!]]


These function take options map whose keys are:
- [[id]]
- [[retry-duration]]
- [[selector]]
- [[patch-mode]]
- [[use-view-transition]]
- [[only-if-missing]]
- [[auto-remove]]
- [[attributes]]

To help manage SSE generators's underlying connection there is:
- [[close-sse!]]
- [[lock-sse!]]
- [[with-open-sse]]

Helper to extract datastar specific data from ring requests:
- [[get-signals]]
- [[datastar-request?]]

Some common utilities for HTTP are also provided:
- [[sse-get]]
- [[sse-post]]
- [[sse-put]]
- [[sse-patch]]
- [[sse-delete]]

Some scripts are provided:
- [[console-log!]]
- [[console-error!]]
- [[redirect!]]
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close