2015-03-03 02:15:56 +00:00
|
|
|
# TodoMVC done with re-frame
|
2015-02-26 01:51:59 +00:00
|
|
|
|
2015-03-06 13:39:09 +00:00
|
|
|
A [re-frame](https://github.com/Day8/re-frame) implementation of [TodoMVC](http://todomvc.com/).
|
2015-02-26 01:51:59 +00:00
|
|
|
|
|
|
|
|
2015-03-03 02:15:56 +00:00
|
|
|
## Setup And Run
|
|
|
|
|
2015-03-06 13:39:09 +00:00
|
|
|
1. Install [Leiningen](http://leiningen.org/) (plus Java).
|
2015-03-03 02:15:56 +00:00
|
|
|
|
|
|
|
1. Get the re-frame repo
|
|
|
|
```
|
|
|
|
git clone https://github.com/Day8/re-frame.git
|
|
|
|
```
|
|
|
|
|
2015-03-06 13:39:09 +00:00
|
|
|
1. cd to the right example directory
|
2015-03-03 02:15:56 +00:00
|
|
|
```
|
|
|
|
cd re-frame/examples/todomvc
|
|
|
|
```
|
|
|
|
|
2015-05-03 09:04:20 +00:00
|
|
|
1. clean build
|
2015-03-03 02:15:56 +00:00
|
|
|
```
|
2015-05-03 09:04:20 +00:00
|
|
|
lein do clean, cljsbuild once
|
2015-03-03 02:15:56 +00:00
|
|
|
```
|
|
|
|
|
2015-03-04 13:45:33 +00:00
|
|
|
1. run
|
2015-03-03 02:15:56 +00:00
|
|
|
```
|
2015-03-06 13:39:09 +00:00
|
|
|
open index.html
|
2015-03-03 02:15:56 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Exploring The Code
|
|
|
|
|
|
|
|
From the re-frame readme:
|
|
|
|
```
|
|
|
|
To build a re-frame app, you:
|
|
|
|
- design your app's data structure (data layer)
|
|
|
|
- write and register subscription functions (query layer)
|
|
|
|
- write Reagent component functions (view layer)
|
|
|
|
- write and register event handler functions (control layer and/or state transition layer)
|
|
|
|
```
|
|
|
|
|
2015-03-06 13:39:09 +00:00
|
|
|
In `src`, there's a matching set of files (each small):
|
|
|
|
```
|
|
|
|
src
|
|
|
|
├── core.cljs <--- entry point, plus history
|
|
|
|
├── db.cljs <--- data related (data layer)
|
|
|
|
├── subs.cljs <--- subscription handlers (query layer)
|
|
|
|
├── views.cljs <--- reagent components (view layer)
|
|
|
|
└── handlers.cljs <--- event handlers (control/update layer)
|
|
|
|
```
|
2015-03-03 02:15:56 +00:00
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
2015-03-06 13:39:09 +00:00
|
|
|
Various:
|
|
|
|
- The [offical reagent example](https://github.com/reagent-project/reagent/tree/master/examples/todomvc).
|
|
|
|
- There's also a sibling example (under construction) called TodoMVC-plus which is a more complete example, including testing etc.
|
|
|
|
- Look at the [re-frame Wiki](https://github.com/Day8/re-frame/wiki).
|