Commit 45ca9c19d8bf4ca58b166e0097d56a1d840cef49
add sync back to about.obs.*
Matt McKegg committed on 6/27/2017, 6:08:59 AMParent: 72b57dbd890f33a17693afa0ca4357d5185af592
Files changed
about/obs.js | changed |
about/obs.js | |||
---|---|---|---|
@@ -27,9 +27,10 @@ | |||
27 | 27 … | ] | |
28 | 28 … | }) | |
29 | 29 … | ||
30 | 30 … | exports.create = function (api) { | |
31 | - var sync = Value(false) | ||
31 … | + var syncValue = Value(false) | ||
32 … | + var sync = computed(syncValue, x => x) | ||
32 | 33 … | var cache = null | |
33 | 34 … | ||
34 | 35 … | return nest({ | |
35 | 36 … | 'about.obs': { | |
@@ -51,30 +52,34 @@ | |||
51 | 52 … | groupedValues | |
52 | 53 … | } | |
53 | 54 … | }) | |
54 | 55 … | ||
55 | - | ||
56 | 56 … | function valueFrom (id, key, author) { | |
57 | 57 … | if (!ref.isLink(id)) throw new Error('About requires an ssb ref!') | |
58 | - return computed([get(id), key, author], getValueFrom) | ||
58 … | + return withSync(computed([get(id), key, author], getValueFrom)) | ||
59 | 59 … | } | |
60 | 60 … | ||
61 | 61 … | function latestValue (id, key) { | |
62 | 62 … | if (!ref.isLink(id)) throw new Error('About requires an ssb ref!') | |
63 | - return computed([get(id), key], getLatestValue) | ||
63 … | + return withSync(computed([get(id), key], getLatestValue)) | ||
64 | 64 … | } | |
65 | 65 … | ||
66 | 66 … | function socialValue (id, key, defaultValue) { | |
67 | 67 … | if (!ref.isLink(id)) throw new Error('About requires an ssb ref!') | |
68 | 68 … | var yourId = api.keys.sync.id() | |
69 | - return computed([get(id), key, id, yourId, defaultValue], getSocialValue) | ||
69 … | + return withSync(computed([get(id), key, id, yourId, defaultValue], getSocialValue)) | ||
70 | 70 … | } | |
71 | 71 … | ||
72 | 72 … | function groupedValues (id, key) { | |
73 | 73 … | if (!ref.isLink(id)) throw new Error('About requires an ssb ref!') | |
74 | - return computed([get(id), key], getGroupedValues) | ||
74 … | + return withSync(computed([get(id), key], getGroupedValues)) | ||
75 | 75 … | } | |
76 | 76 … | ||
77 … | + function withSync (obs) { | ||
78 … | + obs.sync = sync | ||
79 … | + return obs | ||
80 … | + } | ||
81 … | + | ||
77 | 82 … | function get (id) { | |
78 | 83 … | if (!ref.isLink(id)) throw new Error('About requires an ssb ref!') | |
79 | 84 … | load() | |
80 | 85 … | if (!cache[id]) { | |
@@ -108,10 +113,10 @@ | |||
108 | 113 … | state.set(lastState) | |
109 | 114 … | } | |
110 | 115 … | } | |
111 | 116 … | ||
112 | - if (!sync()) { | ||
113 | - sync.set(true) | ||
117 … | + if (!syncValue()) { | ||
118 … | + syncValue.set(true) | ||
114 | 119 … | } | |
115 | 120 … | }) | |
116 | 121 … | ) | |
117 | 122 … | } |
Built with git-ssb-web