From 742a8d357589485d39bf1e2902d2760935662a29 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Sun, 1 Feb 2015 15:29:04 +0100 Subject: [PATCH] Add some preliminary docs --- CHANGELOG.md | 4 ++++ src/reagent/core.cljs | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 048309f..6a02350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ## Upcoming +- Reagent no longer bundles React. Instead it uses cljsjs/react as a dependency. This means that you should no longer specify React in `:preamble` in your project.clj. + +- `cursor` is re-written, to be more efficient and flexible. + - `render` now forces a deep update of all components, to make it more convenient to use with e.g. figwheel. - Renamed `as-component` to `as-element`, to match React's new terminology better (old name still works, though, for backward compatiblity). diff --git a/src/reagent/core.cljs b/src/reagent/core.cljs index 45d20e2..3881570 100644 --- a/src/reagent/core.cljs +++ b/src/reagent/core.cljs @@ -212,10 +212,22 @@ the specified path within the wrapped Reagent atom. e.g., ... (reset! c 42) ;; equivalent to (swap! ra assoc-in [:nested :content] 42) ... (swap! c inc) ;; equivalence to (swap! ra update-in [:nested :content] inc) ) + +The first parameter can also be a function, that should look something +like this: + +(defn digit-filter + ([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. " ([src path] (ratom/cursor src path))) + ;; Utilities (defn next-tick