git ssb

0+

mixmix / ssb-server-channel



Commit 3dc4b5b95868ad563f830588d2c4230a00d42edf

update readme

mix irving committed on 2/15/2018, 3:01:31 AM
Parent: ac0d14ed0e63ad2aa14397166cf4cdbb9961ab0c

Files changed

README.mdchanged
index.jschanged
README.mdView
@@ -23,46 +23,37 @@
2323 Get the channels and who is subscribed where `cb(err, data)` is called with `data` of form:
2424
2525 ```js
2626 {
27- [ChannelName]: Set // set of FeedIds of users subscribed to that channel
27 + [ChannelName]: [
28 + [FeedId, Timestamp],
29 + [FeedId, Timestamp],
30 + ]
2831 }
2932 ```
3033
3134 e.g
3235
3336 ```js
3437 {
35- 'ssb-learning': Set { '@gaQw6z...', '@ye+QM09...' },
36- 'brazil': Set { '@gaQw6z...' }
38 + learning: [
39 + ['@gaQw6z...', 1518663315275],
40 + ['@ye+QM09...', 1518663311233]
41 + ],
42 + brazil: [
43 + ['@gaQw6z...', 1518663129468],
44 + ]
3745 }
3846 ```
3947
40-Check your [Set methods **on MDN**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
4148
42-And if you really need an Array :
43-
44-```js
45-const s = new Set ()
46-set.add('mixmix')
47-set.add('soapdog')
48-
49-[...s] // => ['mixmix', 'soapdog']
50-Array.from(s) // => ['mixmix', 'soapdog']
51-```
52-
53-
5449 ### server.channel.get(cb)
5550
5651 Get the current state of the channel view. This will wait until the view is up to date, if necessary.
5752
5853 `cb(err, data)` is a standard callback function where `data` is of the form:
5954
60-```js
61-{
62- [ChannelName]: Set // set of FeedIds of users subscribed to that channel
63-}
64-```
55 +(same as `channel.subscriptions` at the moment)
6556
6657 ### server.channel.stream() => pull-stream source
6758
6859 Be careful, this is a stream which provides:
index.jsView
@@ -13,10 +13,8 @@
1313 subscriptions: 'async',
1414 reduce: 'sync'
1515 },
1616 init: (server, config) => {
17- // console.log('///// CHANNELS plugin loaded /////')
18-
1917 const view = server._flumeUse(
2018 'channel',
2119 FlumeView(FLUME_VIEW_VERSION, reduce, map, null, initialState())
2220 )
@@ -24,9 +22,9 @@
2422 return {
2523 get: view.get,
2624 subscriptions: view.get,
2725 stream: view.stream,
28- reduce
26 + reduce // TODO - remove this when flumeview offers something similar
2927 }
3028 }
3129 }
3230
@@ -74,34 +72,4 @@
7472
7573 return soFar
7674 }
7775
78-// state:
79-// {
80-// [Channel]: [ Set
81-// FeedId
82-// ]
83-// }
84-
85-
86-// {
87-// 'ssb-learning': [
88-// '@ye14....',
89-// '@weandre..',
90-// ],
91-// 'brazil': [
92-// '@weandre..',
93-// ]
94-// }
95-
96-// channel message:
97-// value: {
98-// author: FeedId,
99-// content: {
100-// {
101-// type: 'channel',
102-// channel: String, // ssb-learning
103-// subscribed: Boolean
104-// }
105-// }
106-// }
107-

Built with git-ssb-web