Skip to content

Commit

Permalink
feat: Add core-added event when a core is added to autobase
Browse files Browse the repository at this point in the history
This allows one to react to new cores being added by `autobase-manager`
to the underlying autobase.
  • Loading branch information
lejeunerenard committed Mar 15, 2023
1 parent edc2426 commit bb2219b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import c from 'compact-encoding'
import b4a from 'b4a'
import Hypercore from 'hypercore'
import { difference } from './utils/set-operations.js'
import { EventEmitter } from 'events'

const DEBUG = false

export class AutobaseManager {
export class AutobaseManager extends EventEmitter {
constructor (base, allow, get, storage, opts = {}) {
super()
this.base = base
this.allow = allow
this.get = get
Expand Down Expand Up @@ -171,6 +173,7 @@ export class AutobaseManager {
this._inputKeys.add(b4a.toString(core.key, 'hex'))
await this.base.addInput(core)
}
this.emit('core-added', core, destination)
}
}

Expand Down

0 comments on commit bb2219b

Please sign in to comment.