Skip to content

ipfs@0.41 update: option 1 #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

zebateira
Copy link
Contributor

First option for dealing with the new js ipfs api that always returns iterables.
This first approach adds a for await...of loop.

Screen Shot 2020-02-17 at 7 04 37 PM

  • Still working out how to solve the linting warnings on the monaco editor
  • Although it looks a bit convoluted, it might be a better choice if we don't want to introduce a module when teaching

See original WIP PR: #381

@zebateira zebateira mentioned this pull request Feb 17, 2020
@zebateira zebateira changed the title wip: option one for using the new async iterable api ipfs@0.41 update: option 1 Feb 17, 2020
@zebateira zebateira force-pushed the fix/ipfs-0.41-upgrade-option-1 branch from cba64d4 to 2c38802 Compare February 17, 2020 15:42
@zebateira
Copy link
Contributor Author

Alternatively, we could also take the ipfs.add operation out of the for loop:

Initial code:

/* global ipfs */
const run = async (files) => {
  const result = []
  const operation = // Place your code to add a file or files here

  for await (const resultPart of operation) {
    result.push(resultPart)
  }

  return result
}
return run

Solution code:

/* global ipfs */
const run = async (files) => {
  const result = []
  const operation = ipfs.add(files)

  for await (const resultPart of operation) {
    result.push(resultPart)
  }

  return result
}
return run

@zebateira zebateira closed this Feb 21, 2020
@zebateira zebateira deleted the fix/ipfs-0.41-upgrade-option-1 branch February 21, 2020 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant