Liking cljdoc? Tell your friends :D

hyper.protocols

Protocols for extending hyper's capabilities.

Consumers implementing external state sources (databases, message queues, etc.) should extend the Watchable protocol to enable reactive re-renders via h/watch!.

Protocols for extending hyper's capabilities.

Consumers implementing external state sources (databases, message queues, etc.)
should extend the Watchable protocol to enable reactive re-renders via `h/watch!`.
raw docstring

Watchablecljprotocol

Protocol for types that can be watched for changes. Extend this to allow watch! to observe custom external state sources like databases, message queues, or any stateful resource.

Implementations must:

  • Call (callback old-val new-val) when the watched value changes
  • Support multiple concurrent watches keyed by unique keys
  • Remove the watch cleanly when -remove-watch is called
  • Implement -dispose to release underlying resources (connections, subscriptions, file handles, etc.) when the tab navigates away or disconnects. Return nil. For simple sources like atoms that hold no external resources, -dispose should be a no-op.
Protocol for types that can be watched for changes.
Extend this to allow `watch!` to observe custom external state sources
like databases, message queues, or any stateful resource.

Implementations must:
- Call (callback old-val new-val) when the watched value changes
- Support multiple concurrent watches keyed by unique keys
- Remove the watch cleanly when -remove-watch is called
- Implement -dispose to release underlying resources (connections,
  subscriptions, file handles, etc.) when the tab navigates away
  or disconnects.  Return nil.  For simple sources like atoms that
  hold no external resources, -dispose should be a no-op.

-add-watchclj

(-add-watch this key callback)

Add a watch with the given key. callback is (fn [old-val new-val]).

Add a watch with the given key. callback is (fn [old-val new-val]).

-disposeclj

(-dispose this)

Release any resources held by this source. Called when the tab navigates away or disconnects, after all watches have been removed. No-op for sources that hold no external resources.

Release any resources held by this source. Called when the tab
navigates away or disconnects, after all watches have been removed.
No-op for sources that hold no external resources.

-remove-watchclj

(-remove-watch this key)

Remove a previously added watch by key.

Remove a previously added watch by key.
sourceraw 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