Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

pubsub.subscribe throws an error when trying to use it promise-way #1137

Closed
negamaxi opened this issue Dec 8, 2017 · 0 comments
Closed

pubsub.subscribe throws an error when trying to use it promise-way #1137

negamaxi opened this issue Dec 8, 2017 · 0 comments
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@negamaxi
Copy link
Contributor

negamaxi commented Dec 8, 2017

  • Version: 0.27.0
  • Platform: Linux
  • Subsystem: x64

Type: Bug

Severity: High

Description: pubsub.subscribe throws an error when trying to use it promise-way. Seems to be related with #1129.

Steps to reproduce the error:

await ipfs.pubsub.subscribe(topic, handleMessage)
// Uncaught TypeError: callback is not a function

Therefore callback-way is the only available for now. Here is simple workaround:

  await new Promise((resolve, reject) => {
    ipfs.pubsub.subscribe(topic, handleMessage, err => {
      if (err) {
        reject(err)
      } else {
        resolve(err)
      }
    })
  })
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

No branches or pull requests

2 participants