This re-frame library contains an cookie effect handler. The handler can be addressed by :cookie
and uses the goog.net.cookies API.
Add the following dependency to your project.cljs
:
See the following minimal code example or the test.cljs.
(ns your.project
(:require [re-frame.core :as re-frame]
[re-frame-cookie-fx.core]))
(re-frame/reg-event-fx
:initialize
;; injects the cookie :re-frame-cookie-fx.core/db into your event handler
[(re-frame/inject-cofx :cookie)]
(fn [cofx _]
;; gets the current counter value from the cookie and / or creates it with the value 0
{:cookie (update (:cookie cofx) :counter (fnil identity 0))}))
I´d be thankful to receive patches, comments and constructive criticism.
Hope the package is useful :-)
Can you improve this documentation? These fine people already did:
JT Knabenschuh & jtkDvlpEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close