Readme WIP

This commit is contained in:
mike-thompson-day8 2014-12-11 16:37:35 +11:00
parent b9563bb499
commit 0dc4c9d8ae
1 changed files with 9 additions and 6 deletions

View File

@ -41,6 +41,7 @@ allow for the two way flow of data.
re-frame implements the two way flow of data into and re-frame implements the two way flow of data into and
out of views by using two, one-way flows. out of views by using two, one-way flows.
---------------------------------
## The Parts ## The Parts
To explain re-frame, we'll now incrementally To explain re-frame, we'll now incrementally
@ -74,23 +75,24 @@ From here on, we'll assume that this part of the framework looks like this:
(def ratom (reagent/atom {})) ;; a reagent atom, containing a map (def ratom (reagent/atom {})) ;; a reagent atom, containing a map
``` ```
It is useful to actively imagine our ratom as an (in memory) database. It is useful to actively imagine this ratom as an (in memory) database.
It will contain structured data (perhaps with a formal [Prismatic Schema] definition). It will contain structured data (perhaps with a formal [Prismatic Schema] spec).
You will need to query that data. You will perform CRUD You will need to query that data. You will perform CRUD
and other transformations on it. You'll often want to transact on this and other transformations on it. You'll often want to transact on this
database atomically, etc. So "in-memory database" database atomically, etc. So "in-memory database"
seems a more useful paradigm than plain old atom. In our implementation, we actually seems a more useful paradigm than plain old atom. In our implementation, we actually
use the name `db` to drive home the point. use the name `db` to drive home the point.
Finally, `ratom` doesn't actually have to be a ratom containing a map. re-frame Finally, `ratom` doesn't actually have to be a ratom containing a map. In theory, re-frame
imposes no requirement here. It could be a [datascript] database. Its just a datastore imposes no requirement here. It could be a [datascript] database. Its just a reactive datastore
of some description. of some description.
------------------------
##### Magic Ratoms ##### Magic Ratoms
ratoms have a key feature. They act like normal clojurescript atoms, **plus** they allow ratoms have a key feature. They act like normal ClojureScript atoms, **plus** they allow
you to create reactive functions similar to `lift` in [Elm] or `defc=` in [hoplon]. you to create reactive functions similar to `lift` in [Elm] or `defc=` in [hoplon].
You create these reactive functions via the reagent macros `reaction` or `run!`. You create these reactive functions via the reagent macro `reaction` (or `run!`).
```clojure ```clojure
(ns example1 (ns example1
@ -151,6 +153,7 @@ and automatically, new hiccup is produced.
This is not a tutorial on how to write reagent components, but let's This is not a tutorial on how to write reagent components, but let's
talk briefly about the "data in" bit. Turns out there are two ways talk briefly about the "data in" bit. Turns out there are two ways
data flows into components: data flows into components:
1. the data is supplied as component parameters, typically from a parent 1. the data is supplied as component parameters, typically from a parent
component. There tends to be a component. There tends to be a
hierarchy of components and data often flows from parent to child hierarchy of components and data often flows from parent to child