Liking cljdoc? Tell your friends :D

homebase.cache

A homebase cache intermediates between a view layer like React or Reagent and a data layer like Datascript or Datahike.

It ensures that as data changes the view is incremently updated to reflect the most recent state while maintaining consistency/transactionality, performing all updates for a transaction simultaneously.

The cache takes the form of a map where components (identified by site-ids) can subscribe to updates of specific data by associng change-handlers into the cache.

E.g.

{:ea
{["EntityId" :attribute]
 {"uuid-for-a-component-or-'hook'" ; multiple components may subscribe to changes in the same datom so each gets their own change-handler
  (fn on-entity-attr-change-handler-fn
    [{:db-after ; the db value that corresponds with this update. Should be used by the consuming component to update the view so it stays in sync because all change-handlers use the same DB snapshot for the same TX.
      :datom ; the updated datom
      :site-id "uuid-for-a-component-or-'hook'"}]
  ; INSERT code to update the view in this component with the newest state of this datom
    )}}
:q
{['[:find ?e ?a ?v
    :where [?e ?a ?v]]
  other-inputs]
 {"uuid-for-a-component-or-'hook'" ; multiple components may subscribe to changes in the same query so each gets their own change-handler
  (fn on-query-change-handler-fn
    [{:db-after ; the db value that corresponds with this update. Should be used by the consuming component to update the view so it stays in sync because all change-handlers use the same DB snapshot for the same TX.
      :site-id "uuid-for-a-component-or-'hook'"}]
  ; INSERT code to update the view with the latest results of the query
    )}}}

The cache takes care of appropriately invoking change-handlers after every transaction.

A homebase cache intermediates between a view layer like React or Reagent and a data layer like Datascript or Datahike.

It ensures that as data changes the view is incremently updated to reflect the most recent state while maintaining consistency/transactionality, performing all updates for a transaction simultaneously.

The cache takes the form of a map where components (identified by site-ids) can subscribe to updates of specific data by associng change-handlers into the cache.

E.g.

```clojure
{:ea
{["EntityId" :attribute]
 {"uuid-for-a-component-or-'hook'" ; multiple components may subscribe to changes in the same datom so each gets their own change-handler
  (fn on-entity-attr-change-handler-fn
    [{:db-after ; the db value that corresponds with this update. Should be used by the consuming component to update the view so it stays in sync because all change-handlers use the same DB snapshot for the same TX.
      :datom ; the updated datom
      :site-id "uuid-for-a-component-or-'hook'"}]
  ; INSERT code to update the view in this component with the newest state of this datom
    )}}
:q
{['[:find ?e ?a ?v
    :where [?e ?a ?v]]
  other-inputs]
 {"uuid-for-a-component-or-'hook'" ; multiple components may subscribe to changes in the same query so each gets their own change-handler
  (fn on-query-change-handler-fn
    [{:db-after ; the db value that corresponds with this update. Should be used by the consuming component to update the view so it stays in sync because all change-handlers use the same DB snapshot for the same TX.
      :site-id "uuid-for-a-component-or-'hook'"}]
  ; INSERT code to update the view with the latest results of the query
    )}}}
```

The cache takes care of appropriately invoking change-handlers after every transaction.
raw docstring

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

× close