git ssb

1+

Daan Patchwork / patchwork



Tree: 4d9f238ff73f7136cd292da88f06c17fe1a8c445

Files: 4d9f238ff73f7136cd292da88f06c17fe1a8c445 / lib / depject / message / obs / name.js

589 bytesRaw
1const Value = require('mutant/value')
2const ref = require('ssb-ref')
3const nest = require('depnest')
4
5exports.needs = nest('message.async.name', 'first')
6
7exports.gives = nest('message.obs.name')
8
9exports.create = function (api) {
10 return nest('message.obs.name', function (id) {
11 if (!ref.isLink(id)) throw new Error('an id must be specified')
12 const value = Value(id.substring(0, 10) + '...')
13
14 if (ref.isMsg(id)) {
15 api.message.async.name(id, function (err, name) {
16 if (err) console.error(err)
17 else value.set(name)
18 })
19 }
20
21 return value
22 })
23}
24

Built with git-ssb-web