git ssb

2+

dinoworm ๐Ÿ› / ssb-graphviz



Tree: ca718f616a051e93adeb22faa3fc06646f667973

Files: ca718f616a051e93adeb22faa3fc06646f667973 / profiles / app.js

685 bytesRaw
1const { assign } = Object
2const async = require('pull-async')
3
4const { SET_ONE, FETCH_ONE, setOne } = require('./actions')
5
6module.exports = ProfilesApp
7
8function ProfilesApp (config) {
9 return {
10 init: () => ({
11 model: {},
12 }),
13 update: {
14 [SET_ONE]: (model, profile) => ({
15 model: assign({}, model, { [profile.id]: profile })
16 })
17 },
18 run: {
19 [FETCH_ONE]: (id) => {
20 return async(cb => {
21 xhr({
22 url: `/api/profiles/${profile}`,
23 json: true
24 }, (err, resp, { body } = {}) => {
25 if (err) return cb(err)
26 cb(null, setOne(body))
27 })
28 })
29 },
30 }
31 }
32}
33

Built with git-ssb-web