Commit 707149d74410fd5c3373405e52ba90fbb4122514
more dream docs
Michael Williams committed on 1/12/2017, 10:52:05 PMParent: 484bd0ad26fdc6bfbd07fdf41b9038ec595bde0d
Files changed
README.md | changed |
README.md | ||
---|---|---|
@@ -64,25 +64,17 @@ | ||
64 | 64 | ``` |
65 | 65 | |
66 | 66 | ### test |
67 | 67 | |
68 | -runs tests | |
68 | +runs [`pull-test`](https://github.com/ahdinosaur/pull-test) tests | |
69 | 69 | |
70 | -```shell | |
71 | -catstack test | |
72 | -``` | |
73 | - | |
74 | -#### test:spec | |
75 | - | |
76 | -runs [tape](https://www.npmjs.com/package/tape) tests | |
77 | - | |
78 | 70 | can optionally take a [glob](https://www.npmjs.com/package/glob) |
79 | 71 | |
80 | 72 | ```shell |
81 | 73 | npm run test -- './todos/**/*.test.js' |
82 | 74 | ``` |
83 | 75 | |
84 | -default glob is `./**/*.test.js` | |
76 | +default glob is `./**/*.test.js` ignoring `node_modules` | |
85 | 77 | |
86 | 78 | ### lint |
87 | 79 | |
88 | 80 | checks for [standard style](http://standardjs.com) |
@@ -96,9 +88,9 @@ | ||
96 | 88 | default glob is `./**/*.js` ignoring `node_modules` |
97 | 89 | |
98 | 90 | ### format |
99 | 91 | |
100 | -converts to [standard](http://standardjs.com) if possible | |
92 | +converts to [standard style](http://standardjs.com) if possible | |
101 | 93 | |
102 | 94 | can optionally take a [glob](https://www.npmjs.com/package/glob) |
103 | 95 | |
104 | 96 | ```shell |
@@ -110,12 +102,12 @@ | ||
110 | 102 | ### db:clean |
111 | 103 | |
112 | 104 | ## directory structure |
113 | 105 | |
114 | -- `/config/` | |
115 | - - `/config/index.js` | |
116 | - - `/config/${ NODE_ENV }.js` | |
117 | -- `/${ domain }/` | |
106 | +- `config/` | |
107 | + - `config/index.js` | |
108 | + - `config/${ NODE_ENV }.js` | |
109 | +- `${ domain }/` | |
118 | 110 | - tests are any files that end in `.test.js` |
119 | 111 | |
120 | 112 | ### domain overview |
121 | 113 | |
@@ -131,22 +123,126 @@ | ||
131 | 123 | - `elements/*.js`: exports presentation views |
132 | 124 | - `helpers/*.js`: exports helper functions |
133 | 125 | - `service.js`: exports [`vas`](https://github.com/ahdinosaur/vas) service |
134 | 126 | |
135 | -### `/${ domain }/state.js` | |
127 | +### `${ domain }/state.js` | |
136 | 128 | |
129 | +```js | |
130 | +// cats/state.js` | |
131 | +module.exports = { | |
132 | + create: () => ({ | |
133 | + state: { | |
134 | + model: {}, | |
135 | + effect: null | |
136 | + } | |
137 | + }) | |
138 | +} | |
139 | +``` | |
140 | + | |
137 | 141 | ### `/${ domain }/actions/*.js` |
138 | 142 | |
143 | +```js | |
144 | +// cats/actions/create.js | |
145 | +module.exports = { | |
146 | + create: () => ({ | |
147 | + update: (model, action) => { | |
148 | + console.log('cat:create', model, action) | |
149 | + return model | |
150 | + } | |
151 | + }) | |
152 | +} | |
153 | +``` | |
154 | + | |
139 | 155 | ### `/${ domain }/effects/*.js` |
140 | 156 | |
157 | +```js | |
158 | +// cats/effects/fetch.js | |
159 | +module.exports = { | |
160 | + create: () => ({ | |
161 | + run: (effect) => { | |
162 | + console.log('cat:fetch', effect) | |
163 | + } | |
164 | + }) | |
165 | +} | |
166 | +``` | |
167 | + | |
141 | 168 | ### `/${ domain }/getters.js` |
142 | 169 | |
170 | +```js | |
171 | +// cats/getters/getCats.js | |
172 | +module.exports = { | |
173 | + create: () => (state) => state.cats | |
174 | +} | |
175 | +``` | |
176 | + | |
143 | 177 | ### `/${ domain }/pages/*.js` |
144 | 178 | |
179 | +```js | |
180 | +// cats/pages/show.js | |
181 | +module.exports = { | |
182 | + needs: { | |
183 | + layout: 'first', | |
184 | + cats: { | |
185 | + profile: 'first' | |
186 | + } | |
187 | + }, | |
188 | + create: (api) => ({ | |
189 | + route: '/cats/:catId', | |
190 | + view: api.layout((model) => api.cats.profile) | |
191 | + }) | |
192 | +} | |
193 | +``` | |
194 | + | |
145 | 195 | ### `/${ domain }/elements/*.js` |
146 | 196 | |
197 | +```js | |
198 | +// cats/elements/profile.js | |
199 | +module.exports = { | |
200 | + needs: { | |
201 | + html: 'first' | |
202 | + }, | |
203 | + create: (api) => ({ | |
204 | + view: (cat) => api.html` | |
205 | + <div>${cat.name}</div> | |
206 | + ` | |
207 | + }) | |
208 | +} | |
209 | +``` | |
210 | + | |
147 | 211 | ### `/${ domain }/service.js` |
148 | 212 | |
213 | +```js | |
214 | +// cats/service.js | |
215 | +module.exports = { | |
216 | + needs: { | |
217 | + data: 'first' | |
218 | + }, | |
219 | + manifest: { | |
220 | + all: 'source', | |
221 | + get: 'async' | |
222 | + }, | |
223 | + create: function (api) { | |
224 | + const cats = [{ | |
225 | + name: 'Fluffy' | |
226 | + }, { | |
227 | + name: 'Zoe' | |
228 | + }] | |
229 | + | |
230 | + return { | |
231 | + methods: { all, get } | |
232 | + } | |
233 | + | |
234 | + function all () { | |
235 | + return pull.values(cats) | |
236 | + } | |
237 | + | |
238 | + function get (id, cb) { | |
239 | + cb(null, data[id]) | |
240 | + } | |
241 | + } | |
242 | +}) | |
243 | +``` | |
244 | + | |
149 | 245 | ## FAQ |
150 | 246 | |
151 | 247 | ### how do i do relations between models? |
152 | 248 |
Built with git-ssb-web