Skip to content

Add react function for working with exteral atom-like types #546

@pepijndevos

Description

@pepijndevos

Reagent comes with several atom-like types that implement IDeref and IWatchable, but to my knowledge does not support implementing your own data sources. In Rum there is a react function that basically sets up the watcher and calls deref. Could Reagent support the same? From my limited understanding it'd basically be

(defn react [a]
  (notify-deref-watcher! a)
  @a)

This would enable implementing elegant reactive behavior over JS libraries, websockets, localstorage, you name it. Anything that supports taking the value and notifying changes.

Note that notify-deref-watcher! itself is a private function, so it's currently not kosher to implement this externally.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions