Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)
- [Lead Maintainer](#lead-maintainer)
- [Table of Contents](#table-of-contents)
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Setup](#setup)
- [Get](#get)
- [Put](#put)
- [Unsubscribe](#unsubscribe)
- [Contribute](#contribute)
- [License](#license)

### Install

Expand Down Expand Up @@ -62,22 +68,21 @@ const dsPubsub = new DatastorePubsub(pubsub, datastore, peerId, validator)
#### Get

```js
dsPubsub.get(key, callback)
const buf = await dsPubsub.get(key)
```

Try to subscribe a topic with Pubsub and receive the current local value if available.

Arguments:

- `key` (Buffer): a key representing a unique identifier of the object to subscribe.
- `callback` (function): operation result.

`callback` must follow `function (err, data) {}` signature, where `err` is an error if the operation was not successful. If no `err` is received, a `data` is received containing the most recent known record stored (`Buffer`).
Returns `Promise<Buffer>` containing the most recent known record stored.

#### Put

```js
dsPubsub.put(key, val, callback)
await dsPubsub.put(key, val)
```

Publishes a value through pubsub.
Expand All @@ -86,14 +91,13 @@ Arguments:

- `key` (Buffer): a key representing a unique identifier of the object to publish.
- `val` (Buffer): value to be propagated.
- `callback` (function): operation result.

`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
Returns `Promise<void>`

#### Unsubscribe

```js
dsPubsub.unsubscribe(key, callback)
await dsPubsub.unsubscribe(key)
```

Unsubscribe a previously subscribe value.
Expand All @@ -102,6 +106,8 @@ Arguments:

- `key` (Buffer): a key representing a unique identifier of the object to publish.

Returns `Promise<void>`

## Contribute

Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipns/issues)!
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,23 @@
},
"homepage": "https://github.com/ipfs/js-datastore-pubsub#readme",
"dependencies": {
"assert": "^1.4.1",
"async": "^2.6.2",
"debug": "^4.1.1",
"err-code": "^1.1.2",
"interface-datastore": "~0.6.0",
"err-code": "^2.0.0",
"interface-datastore": "~0.7.0",
"multibase": "~0.6.0"
},
"devDependencies": {
"aegir": "^18.1.1",
"aegir": "^20.0.0",
"chai": "^4.2.0",
"delay": "^4.3.0",
"detect-node": "^2.0.4",
"dirty-chai": "^2.0.1",
"ipfs": "~0.34.4",
"ipfsd-ctl": "~0.42.0",
"libp2p-record": "~0.6.2",
"sinon": "^7.2.4"
"ipfs": "~0.37.0",
"ipfs-http-client": "^33.0.0",
"ipfsd-ctl": "^0.47.2",
"libp2p-record": "~0.7.0",
"promisify-es6": "^1.0.3",
"sinon": "^7.4.1"
},
"contributors": [
"Vasco Santos <[email protected]>",
Expand Down
Loading