Liking cljdoc? Tell your friends :D

License: MIT Clojars Project

Cookie effect handler for re-frame

This re-frame library contains an cookie effect handler. The handler can be addressed by :cookie and uses the goog.net.cookies API.

Getting started

Get it / add dependency

Add the following dependency to your project.cljs:
Clojars Project

Usage

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))}))

Appendix

I´d be thankful to receive patches, comments and constructive criticism.

Hope the package is useful :-)

Can you improve this documentation?Edit on GitHub

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

× close