README.mdView |
---|
9 | 9 … | - github: `git@github.com:ssbc/scuttle-poll.git` |
10 | 10 … | |
11 | 11 … | ## Usage |
12 | 12 … | |
| 13 … | +### Init |
13 | 14 … | ```js |
14 | | -var isPoll = require('scuttle-poll/isPoll') |
15 | | - |
16 | | -isPoll(msg) |
17 | | -// => Boolean |
| 15 … | +var Sbot = require('ssb-client') |
| 16 … | +Sbot((err, server) => { |
| 17 … | + if (err) { |
| 18 … | + return console.log(err) |
| 19 … | + } |
| 20 … | + var ScuttlePoll = require('scuttle-poll') |
| 21 … | + var scuttlePoll = ScuttlePoll(server) |
| 22 … | +}) |
18 | 23 … | ``` |
| 24 … | +where `server` is a scuttlebot instance (or a remote connection provided by `ssb-client`) |
19 | 25 … | |
| 26 … | +Note - `server` can also be an observeable which resolves to a scuttlebot instance |
|
| 27 … | +(this is more experimental, it will turn your sync functions into obs functions) |
| 28 … | + |
| 29 … | +This returns an object with methods defined in `methods.js` that looks like: |
| 30 … | + |
20 | 31 … | ```js |
21 | | -var scuttle = require('scuttle-poll')(server) |
22 | 32 … | |
23 | | -var opts = { |
24 | | - title: 'where shall we have our community meeting?' |
25 | | - choices: [ |
26 | | - 'in person', |
27 | | - 'talky.io', |
28 | | - 'mumble', |
29 | | - ] |
| 33 … | +{ |
| 34 … | + poll: { |
| 35 … | + async: { |
| 36 … | + chooseOne: |
| 37 … | + get: |
| 38 … | + }, |
| 39 … | + sync: { |
| 40 … | + isPoll: |
| 41 … | + isChooseOnePoll: |
| 42 … | + } |
| 43 … | + }, |
| 44 … | + position: { |
| 45 … | + async: { |
| 46 … | + chooseOne: |
| 47 … | + position: |
| 48 … | + |
| 49 … | + }, |
| 50 … | + sync: { |
| 51 … | + isPosition: |
| 52 … | + chooseOneResults: |
| 53 … | + } |
| 54 … | + } |
30 | 55 … | } |
31 | | -scuttle.poll.async.publishChooseOne(opts, (err, poll) => { |
32 | | - if (err) throw err |
33 | 56 … | |
34 | | - var myPosition |
35 | | - scuttle.position.async.publishPosition(myPosition, cb) |
36 | | -}) |
37 | 57 … | ``` |
38 | | -where `server` is a scuttlebot instance (or a remote connection provided by `ssb-client`) |
39 | 58 … | |
40 | | -Note - `server` can also be an observeable which resolves to a scuttlebot instance |
41 | | -(this is more experimental, it will turn your sync functions into obs functions) |
42 | | - |
43 | | - |
44 | 59 … | ## Dependencies |
45 | 60 … | |
46 | 61 … | Requires a scuttlebutt server with the following plugins installed: |
47 | 62 … | - `ssb-backlinks` |
49 | 64 … | |
50 | 65 … | ## API |
51 | 66 … | |
52 | 67 … | ```js |
53 | | -var Scuttle = require('scuttle-poll') |
54 | | -var scuttle = Scuttle(server) |
| 68 … | +var ScuttlePoll = require('scuttle-poll') |
| 69 … | +var scuttlePoll = ScuttlePoll(server) |
55 | 70 … | ``` |
56 | 71 … | |
57 | 72 … | ### Methods |
58 | 73 … | |