git ssb

1+

dinoworm ๐Ÿ› / catstack



Commit 707149d74410fd5c3373405e52ba90fbb4122514

more dream docs

Michael Williams committed on 1/12/2017, 10:52:05 PM
Parent: 484bd0ad26fdc6bfbd07fdf41b9038ec595bde0d

Files changed

README.mdchanged
README.mdView
@@ -64,25 +64,17 @@
6464 ```
6565
6666 ### test
6767
68-runs tests
68+runs [`pull-test`](https://github.com/ahdinosaur/pull-test) tests
6969
70-```shell
71-catstack test
72-```
73-
74-#### test:spec
75-
76-runs [tape](https://www.npmjs.com/package/tape) tests
77-
7870 can optionally take a [glob](https://www.npmjs.com/package/glob)
7971
8072 ```shell
8173 npm run test -- './todos/**/*.test.js'
8274 ```
8375
84-default glob is `./**/*.test.js`
76+default glob is `./**/*.test.js` ignoring `node_modules`
8577
8678 ### lint
8779
8880 checks for [standard style](http://standardjs.com)
@@ -96,9 +88,9 @@
9688 default glob is `./**/*.js` ignoring `node_modules`
9789
9890 ### format
9991
100-converts to [standard](http://standardjs.com) if possible
92+converts to [standard style](http://standardjs.com) if possible
10193
10294 can optionally take a [glob](https://www.npmjs.com/package/glob)
10395
10496 ```shell
@@ -110,12 +102,12 @@
110102 ### db:clean
111103
112104 ## directory structure
113105
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 }/`
118110 - tests are any files that end in `.test.js`
119111
120112 ### domain overview
121113
@@ -131,22 +123,126 @@
131123 - `elements/*.js`: exports presentation views
132124 - `helpers/*.js`: exports helper functions
133125 - `service.js`: exports [`vas`](https://github.com/ahdinosaur/vas) service
134126
135-### `/${ domain }/state.js`
127+### `${ domain }/state.js`
136128
129+```js
130+// cats/state.js`
131+module.exports = {
132+ create: () => ({
133+ state: {
134+ model: {},
135+ effect: null
136+ }
137+ })
138+}
139+```
140+
137141 ### `/${ domain }/actions/*.js`
138142
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+
139155 ### `/${ domain }/effects/*.js`
140156
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+
141168 ### `/${ domain }/getters.js`
142169
170+```js
171+// cats/getters/getCats.js
172+module.exports = {
173+ create: () => (state) => state.cats
174+}
175+```
176+
143177 ### `/${ domain }/pages/*.js`
144178
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+
145195 ### `/${ domain }/elements/*.js`
146196
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+
147211 ### `/${ domain }/service.js`
148212
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+
149245 ## FAQ
150246
151247 ### how do i do relations between models?
152248

Built with git-ssb-web