Commit 86a0d059a6618c5b0e01793ac5a710c66c9b4dda
Merge branch 'master' of github.com:dominictarr/epidemic-broadcast-trees
Dominic Tarr committed on 6/5/2017, 11:09:42 PMParent: 36fd23a2593c35e462fe4c1a3ff057b0a4dafa83
Parent: 39d19b2a5bb81817b9547ae72ef6c23de93df5cf
Files changed
README.md | changed |
README.md | ||
---|---|---|
@@ -42,9 +42,10 @@ | ||
42 | 42 … | |
43 | 43 … | function createChatModel (id, log) { |
44 | 44 … | //in this example, logs can be a map of arrays, |
45 | 45 … | var logs = {} |
46 | - logs[id] = log || [] | |
46 … | + if(id) logs[id] = log || [] | |
47 … | + | |
47 | 48 … | var onAppend = Obv() |
48 | 49 … | return { |
49 | 50 … | logs: logs, |
50 | 51 … | append: function append (msg) { |
@@ -66,21 +67,22 @@ | ||
66 | 67 … | //and only one value per instance (instead of potentially many named events) |
67 | 68 … | |
68 | 69 … | |
69 | 70 … | var stream = createEbtStream( |
70 | - vectorClock, | |
71 | 71 … | //pass a get(id, seq, cb) |
72 | 72 … | function (id, seq, cb) { |
73 | - if(!chat.logs[id] || !chat.logs[id][seq]) | |
73 … | + if(!chat.logs[id] || !chat.logs[id][seq-1]) | |
74 | 74 … | return cb(new Error('not found')) |
75 | - cb(null, chat.logs[id][seq]) | |
75 … | + cb(null, chat.logs[id][seq-1]) | |
76 | 76 … | }, |
77 | 77 … | //pass append(msg, cb) |
78 | 78 … | function (msg, cb) { |
79 | 79 … | chat.append(msg) |
80 | 80 … | cb() |
81 | 81 … | } |
82 | - ) | |
82 … | + ) ({ | |
83 … | + seqs: vectorClock, | |
84 … | + }) | |
83 | 85 … | |
84 | 86 … | chat.onAppend(stream.onAppend) |
85 | 87 … | |
86 | 88 … | return stream |
Built with git-ssb-web