update reagent-data-views-browserchannel init
This commit is contained in:
parent
a88a24d303
commit
a2ddafa9e3
|
@ -5,15 +5,24 @@
|
||||||
[views.core :as views]
|
[views.core :as views]
|
||||||
[reagent-data-views.server.core :as server]))
|
[reagent-data-views.server.core :as server]))
|
||||||
|
|
||||||
(defn configure-views!
|
(defn- views-send-fn
|
||||||
"performs browserchannel-specific initialization on the views system that is
|
[client-id [view-sig view-data]]
|
||||||
necessary to hook views and reagent-data-views together via browserchannel."
|
|
||||||
[& {:keys [context-fn]}]
|
|
||||||
(views/set-send-fn!
|
|
||||||
(fn [client-id [view-sig view-data]]
|
|
||||||
(log/trace client-id "refresh view" view-sig)
|
(log/trace client-id "refresh view" view-sig)
|
||||||
(browserchannel/send-data! client-id [:views/refresh view-sig view-data])))
|
(browserchannel/send-data! client-id [:views/refresh view-sig view-data]))
|
||||||
(server/set-context-fn! context-fn))
|
|
||||||
|
(defn init-views!
|
||||||
|
"initializes the views system and adds browserchannel-specific configuration
|
||||||
|
to it to enable the necessary hooks into reagent-data-views.
|
||||||
|
you should call this *instead* of views.core/init!. all of the same
|
||||||
|
options can be used. see views.core/init! for more information.
|
||||||
|
|
||||||
|
an additional option :context-fn can be specified which is a function
|
||||||
|
that accepts an initial context map created by reagent-data-views and
|
||||||
|
allows your application to add any information necessary to the context
|
||||||
|
passed to various view system functions (such as auth-fn, namespace-fn, etc)."
|
||||||
|
[views & [options]]
|
||||||
|
(views/init! views views-send-fn options)
|
||||||
|
(server/set-context-fn! (:context-fn options)))
|
||||||
|
|
||||||
(def middleware
|
(def middleware
|
||||||
"clj-browserchannel server-side event middleware. this should be included in the
|
"clj-browserchannel server-side event middleware. this should be included in the
|
||||||
|
|
Loading…
Reference in a new issue