Skip to content

Commit

Permalink
docs: update examples (ipfs#2319)
Browse files Browse the repository at this point in the history
Since I was going through these anyway to ensure they work with [0.37](ipfs#2192) I've updated the examples to use the new [`IPFS.create` constructor](https://github.com/ipfs/js-ipfs#ipfs-constructor) and switched to using the promised API so that we onboard new users to using promises and minimise the disruption caused when ipfs#1670 bubbles up to here.

License: MIT
Signed-off-by: Alan Shaw <[email protected]>
  • Loading branch information
Alan Shaw authored Aug 2, 2019
1 parent 2d7370c commit 1f8684d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"dot-prop": "^5.0.0",
"ipfs": "file:../../",
"ipfs-css": "^0.12.0",
"ipfs-css": "^0.13.1",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"react-scripts": "3.0.1",
Expand Down
10 changes: 1 addition & 9 deletions src/hooks/use-ipfs-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function useIpfsFactory ({ commands }) {
} else {
try {
console.time('IPFS Started')
ipfs = await promiseMeJsIpfs(Ipfs, {})
ipfs = await Ipfs.create()
console.timeEnd('IPFS Started')
} catch (error) {
console.error('IPFS init error:', error)
Expand All @@ -54,11 +54,3 @@ export default function useIpfsFactory ({ commands }) {

return { ipfs, isIpfsReady, ipfsInitError }
}

function promiseMeJsIpfs (Ipfs, opts) {
return new Promise((resolve, reject) => {
const ipfs = new Ipfs(opts)
ipfs.once('ready', () => resolve(ipfs))
ipfs.once('error', err => reject(err))
})
}

0 comments on commit 1f8684d

Please sign in to comment.