Files: c8ebe98ed356a8b95e516ca561f755e05ed43156 / book / obs / struct.js
912 bytesRaw
1 | const nest = require('depnest') |
2 | const { Value, Set, Dict, Struct, forEachPair } = require('mutant') |
3 | |
4 | exports.needs = nest({ |
5 | 'sbot.async.publish': 'first' |
6 | }) |
7 | |
8 | exports.gives = nest('book.obs.struct') |
9 | |
10 | exports.create = function (api) { |
11 | return nest('book.obs.struct', function (opts = {}) { |
12 | const struct = Struct({ |
13 | key: Value(''), |
14 | title: Value(''), |
15 | authors: Value(''), |
16 | description: Value(''), |
17 | images: Set([]), |
18 | subjective: Dict() |
19 | }) |
20 | |
21 | struct.create = function(cb) |
22 | { |
23 | let s = struct() |
24 | |
25 | let commonObj = { |
26 | title: s.title, |
27 | authors: s.authors, |
28 | description: s.description, |
29 | images: s.images |
30 | } |
31 | let subjectiveObj = null |
32 | |
33 | api.sbot.async.publish({ type: 'bookclub', |
34 | common: commonObj, |
35 | subjective: subjectiveObj }, cb) |
36 | } |
37 | |
38 | return struct |
39 | }) |
40 | } |
41 |
Built with git-ssb-web