Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

fix: remove node event emitters #161

Merged
merged 4 commits into from
Feb 10, 2022
Merged

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Feb 9, 2022

Replaces the node EventEmitter with the pure-js EventTarget class.

All events are now instances of Event.

For typing CustomEvent can be used which gives us a typed .detail field.

Tediously EventTarget itself doesn't support typed events (yet?) and node.js doesn't support CustomEvent globally so bit of trickery was required but hopefully this can be removed in future:

import { EventEmitter, CustomEvent } from '@libp2p/interfaces'

interface EventMap {
  'foo': CustomEvent<number>
}

class MyEmitter extends EventEmitter<EventMap> {
  // ... other code here
} 

const emitter = new MyEmitter()

emitter.addEventListener('foo', (evt) => {
  const n = evt.detail // n is a 'number'
})

@achingbrain achingbrain merged commit 221fb6a into master Feb 10, 2022
@achingbrain achingbrain deleted the fix/remove-node-event-emitters branch February 10, 2022 05:43
github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/interfaces-v1.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/logger-v1.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/peer-id-v1.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/tracked-map-v1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/topology-v1.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/peer-id-factory-v1.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/pubsub-v1.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/interface-compliance-tests-v1.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/connection-v1.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/peer-record-v1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Feb 10, 2022
@github-actions
Copy link

🎉 This PR is included in version @libp2p/peer-store-v1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant