Skip to content

Commit

Permalink
feat : add plugin function
Browse files Browse the repository at this point in the history
  • Loading branch information
nuzulul committed Jul 20, 2024
1 parent 6a69e42 commit ade5fa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/webpeerjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,10 @@ class webpeerjs{
mddrs.push(mddr)
this.#dialMultiaddress(mddrs)
}

plugin(callback){
callback(this)
}


/*
Expand Down
5 changes: 5 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ void async function main() {
}, 500)

nodeIdEl.innerHTML = node.id

function testplugin(callback){
console.log('testplugin',callback.id)
}
node.plugin(testplugin)

const updateDiscoveredPeers = () => {
discoveredPeerCountEl.innerHTML = node.IPFS.discoveredPeers.size
Expand Down

0 comments on commit ade5fa7

Please sign in to comment.