Commit 9144ab97554ad603dd57ff8d50d81940ac397cc6
Merge pull request #17 from ssbc/tidy-readme
Tidy readmePiet Geursen authored on 3/12/2018, 2:06:39 AM
GitHub committed on 3/12/2018, 2:06:39 AM
Parent: d2a8bebd8082181882ad9ee29e93d8df75abcb15
Parent: 8fafd9587402e63cb6f4a6e1dbc10135ec69b4f7
Files changed
README.md | changed |
methods.js | changed |
README.md | ||
---|---|---|
@@ -9,39 +9,53 @@ | ||
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 | |
18 | -``` | |
19 | - | |
20 | -```js | |
21 | -var scuttle = require('scuttle-poll')(server) | |
22 | - | |
23 | -var opts = { | |
24 | - title: 'where shall we have our community meeting?' | |
25 | - choices: [ | |
26 | - 'in person', | |
27 | - 'talky.io', | |
28 | - 'mumble', | |
29 | - ] | |
30 | -} | |
31 | -scuttle.poll.async.publishChooseOne(opts, (err, poll) => { | |
32 | - if (err) throw err | |
33 | - | |
34 | - var myPosition | |
35 | - scuttle.position.async.publishPosition(myPosition, cb) | |
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) | |
36 | 22 … | }) |
37 | 23 … | ``` |
38 | 24 … | where `server` is a scuttlebot instance (or a remote connection provided by `ssb-client`) |
39 | 25 … | |
40 | 26 … | Note - `server` can also be an observeable which resolves to a scuttlebot instance |
41 | 27 … | (this is more experimental, it will turn your sync functions into obs functions) |
42 | 28 … | |
29 … | +This returns an object with methods defined in `methods.js` that looks like: | |
43 | 30 … | |
31 … | +```js | |
32 … | +{ | |
33 … | + poll: { | |
34 … | + async: { | |
35 … | + chooseOne: | |
36 … | + get: | |
37 … | + }, | |
38 … | + sync: { | |
39 … | + isPoll: | |
40 … | + isChooseOnePoll: | |
41 … | + } | |
42 … | + }, | |
43 … | + position: { | |
44 … | + async: { | |
45 … | + chooseOne: | |
46 … | + position: | |
47 … | + | |
48 … | + }, | |
49 … | + sync: { | |
50 … | + isPosition: | |
51 … | + chooseOneResults: | |
52 … | + } | |
53 … | + } | |
54 … | +} | |
55 … | + | |
56 … | +``` | |
57 … | + | |
44 | 58 … | ## Dependencies |
45 | 59 … | |
46 | 60 … | Requires a scuttlebutt server with the following plugins installed: |
47 | 61 … | - `ssb-backlinks` |
@@ -49,10 +63,10 @@ | ||
49 | 63 … | |
50 | 64 … | ## API |
51 | 65 … | |
52 | 66 … | ```js |
53 | -var Scuttle = require('scuttle-poll') | |
54 | -var scuttle = Scuttle(server) | |
67 … | +var ScuttlePoll = require('scuttle-poll') | |
68 … | +var scuttlePoll = ScuttlePoll(server) | |
55 | 69 … | ``` |
56 | 70 … | |
57 | 71 … | ### Methods |
58 | 72 … |
methods.js | ||
---|---|---|
@@ -6,9 +6,10 @@ | ||
6 | 6 … | chooseOne: require('./poll/async/chooseOne'), |
7 | 7 … | get: require('./poll/async/get') |
8 | 8 … | }, |
9 | 9 … | sync: { |
10 | - isPoll: require('./poll/sync/isPoll') | |
10 … | + isPoll: require('./poll/sync/isPoll'), | |
11 … | + isChooseOnePoll: require('./poll/sync/isChooseOnePoll') | |
11 | 12 … | // Poll: // this is not exported - doesn't follow the inject pattern atm |
12 | 13 … | } |
13 | 14 … | }, |
14 | 15 … | position: { |
Built with git-ssb-web