holmsand/reagent — pull request #46 by seancorfield (2014-09-09 02:32:31+00:00)
Title: Add cursor support.

(sorry, I should have done this on a feature branch in my repo)

Adds RCursor type: wraps Reagent's RAtom along with a path that provides focus into a specific part of that atom.

Adds reagent.ratom/cursor as a constructor for the RCursor type.

Adds reagent.core/cursor as the public API. This can be called with just a path, and returns a function that accepts a Reagent atom, or with both a path and an atom.

Dereferences of a cursor behave like get-in on the underlying atom with the specified path.

If you reset! a cursor, it behaves like a swap! assoc-in on the underlying atom. If swap! a cursor, it behaves like a swap! update-in on the underlying atom.