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

Commit

Permalink
fix: make start an async event
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Apr 6, 2017
1 parent 4c1b2c5 commit 78ba1e8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
const series = require('async/series')
const Bitswap = require('ipfs-bitswap')
const FloodSub = require('libp2p-floodsub')
const setImmediate = require('async/setImmediate')

module.exports = (self) => {
return (callback) => {
callback = callback || function noop () {}

const done = (err) => {
if (err) {
self.emit('error', err)
setImmediate(() => self.emit('error', err))
return callback(err)
}

self.state.started()
self.emit('start')
setImmediate(() => self.emit('start'))
callback()
}

Expand Down

0 comments on commit 78ba1e8

Please sign in to comment.