Liking cljdoc? Tell your friends :D

lambdacd.event-bus

Entry-point into the LambdaCD event bus.

The event-bus exists to decouple communication between various parts of LambdaCD and allow external libraries to act on or publish events in a LambdaCD instance.

Usage example:

(let [subscription (subscribe ctx :some-topic)
      payloads (only-payload subscription)]
  (<! (go-loop []
        (if-let [event (<! payloads)]
          (do
            (publish! ctx :some-other-topic (:some-value event))
            (recur)))))
  (unsubscribe ctx :some-topic subscription))
Entry-point into the LambdaCD event bus.

The event-bus exists to decouple communication between various parts of LambdaCD and
allow external libraries to act on or publish events in a LambdaCD instance.

Usage example:
```clojure
(let [subscription (subscribe ctx :some-topic)
      payloads (only-payload subscription)]
  (<! (go-loop []
        (if-let [event (<! payloads)]
          (do
            (publish! ctx :some-other-topic (:some-value event))
            (recur)))))
  (unsubscribe ctx :some-topic subscription))
```

initialize-event-bus

(initialize-event-bus ctx)

Initialize everything necessary for an event-bus to run. Returns a ctx that contains everything necessary so others can use the event-bus later on.

Initialize everything necessary for an event-bus to run.
Returns a ctx that contains everything necessary so others can use the event-bus later on.
sourceraw docstring

only-payload

(only-payload subscription)

Takes a subscription channel and returns a channel that contains only the payload.

Takes a subscription channel and returns a channel that contains only the payload.
sourceraw docstring

publish!macro

(publish! ctx topic payload)

Publish an event on a particular topic of the event-bus when calling from a go block.

Publish an event on a particular topic of the event-bus when calling from a go block.
sourceraw docstring

publish!!macro

(publish!! ctx topic payload)

Publish an event on a particular topic of the event-bus when calling from a normal thread.

Publish an event on a particular topic of the event-bus when calling from a normal thread.
sourceraw docstring

subscribe

(subscribe ctx topic)

Subscribe to a particular topic on the event-bus. Returns a subscription channel, i.e. a channel of events and metadata. Use only-payload to get a channel of only event payloads.

Subscribe to a particular topic on the event-bus.
Returns a subscription channel, i.e. a channel of events and metadata.
Use only-payload to get a channel of only event payloads.
sourceraw docstring

unsubscribe

(unsubscribe ctx topic subscription)

Unsubscribe from a channel. Receives the topic we want to unsubscribe from and the subscription channel returned by subscribe.

Unsubscribe from a channel.
Receives the topic we want to unsubscribe from and the subscription channel returned by subscribe.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close