Files: 1006d0c4dde00ee503cde396de716125b96524c1 / lib / depject / progress / html / peer.js
650 bytesRaw
1 | const { computed, when } = require('mutant') |
2 | const nest = require('depnest') |
3 | const renderProgress = require('../../../progress/html/render') |
4 | |
5 | exports.gives = nest('progress.html.peer') |
6 | |
7 | exports.needs = nest({ |
8 | 'progress.obs.peer': 'first', |
9 | 'progress.obs.replicate': 'first' |
10 | }) |
11 | |
12 | exports.create = function (api) { |
13 | return nest('progress.html.peer', function (id) { |
14 | const progress = api.progress.obs.peer(id) |
15 | const feeds = api.progress.obs.replicate().feeds |
16 | const value = computed([progress, feeds], (pending, feeds) => { |
17 | return (feeds - pending) / feeds |
18 | }) |
19 | |
20 | return renderProgress(value, when(progress, '-pending')) |
21 | }) |
22 | } |
23 |
Built with git-ssb-web