Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

chore: update examples in docs to async/await #542

Merged
merged 2 commits into from
Oct 29, 2019

Conversation

PedroMiguelSS
Copy link
Contributor

This PR converts interface-ipfs-core docs examples to use async/await syntax.

Closes #525.

Copy link
Contributor

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's work putting a comment at the top of every file to say that all the APIs that return Promises also accept a final callback parameter that is not listed in the docs.

Please, next time, multiple PRs 🙏

const links = await ipfs.object.links(multihash)
console.log(links)
// Logs:
// []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update this example to include actual content!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a cid that actually has links so that we can demonstrate using the console.log(). Am I right?

SPEC/PUBSUB.md Outdated
@@ -10,30 +10,29 @@

> Subscribe to a pubsub topic.

##### `ipfs.pubsub.subscribe(topic, handler, [options], [callback])`
##### `ipfs.pubsub.subscribe(topic, handler, [options])`

- `topic: String`
- `handler: (msg) => {}` - Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: String, seqno: Buffer, data: Buffer, topicIDs: Array<String>}`.
- `options: Object` - (Optional) Object containing the following properties:
- `discover: Boolean` - (Default: `false`) Will use the DHT to find other peers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you please add a comment that this option is currently unimplemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If discover was the only option and it's not implemented yet, it means that currently there are no options available. Right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, but please leave this here as we need to document onError asap, which you can pass to the HTTP client for dealing with pubsub errors and disconnections.

Any chance you could send a PR for it?

@alanshaw
Copy link
Contributor

ping @PedroMiguelSS

@PedroMiguelSS PedroMiguelSS force-pushed the chore/update-docs-examples-to-async-await branch from d28ea58 to e87014d Compare October 25, 2019 16:29
@PedroMiguelSS
Copy link
Contributor Author

PedroMiguelSS commented Oct 28, 2019

Do you prefer one PR per file/API? @alanshaw

@PedroMiguelSS PedroMiguelSS force-pushed the chore/update-docs-examples-to-async-await branch from e87014d to 74f38f4 Compare October 28, 2019 09:51
@PedroMiguelSS PedroMiguelSS force-pushed the chore/update-docs-examples-to-async-await branch from 74f38f4 to 838bac5 Compare October 29, 2019 10:49
@alanshaw
Copy link
Contributor

Thanks @PedroMiguelSS ❤️

@alanshaw alanshaw merged commit b12f872 into master Oct 29, 2019
@alanshaw alanshaw deleted the chore/update-docs-examples-to-async-await branch October 29, 2019 11:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert examples in docs to async/await
2 participants