From 9260d9b74b640d2abb5aab8ed3408585adafe328 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Mon, 2 Feb 2015 22:14:57 +0100 Subject: [PATCH] More docs for cursor --- src/reagent/core.cljs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/reagent/core.cljs b/src/reagent/core.cljs index 8953b6e..6ccb8ad 100644 --- a/src/reagent/core.cljs +++ b/src/reagent/core.cljs @@ -229,13 +229,17 @@ the specified path within the wrapped Reagent atom. e.g., The first parameter can also be a function, that should look something like this: -(defn digit-filter +(defn set-get ([k] (get-in @state k)) ([k v] (swap! state assoc-in k v))) The function will be called with one argument – the path passed to cursor – when the cursor is deref'ed, and two arguments (path and new value) when the cursor is modified. + +Given that set-get function, (and that state is a Reagent atom, or +another cursor) these cursors are equivalent: +(cursor state [:foo]) and (cursor set-get [:foo]). " ([src path] (ratom/cursor src path)))