polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 352 forks source link

EventEmitter not found error on polkadot api #4622

Closed TopCodeBeast closed 2 years ago

TopCodeBeast commented 2 years ago

Currently, I updated polkadot/api 7.5+ and I get EventEmitter not found I get error here : #eventemitter = new EventEmitter(); I saw the event method is changed.

Cloud you help me?

jacogr commented 2 years ago

The API emit is only internal, ie. it is there to emit events originating from the API.

TopCodeBeast commented 2 years ago

I think if the parser can't parse # symbol?

jacogr commented 2 years ago

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields for private field syntax.

TopCodeBeast commented 2 years ago

it's not #parse error , I tried super() "The API emit is only internal, ie. it is there to emit events originating from the API." Cloud you tell me in detail?

jacogr commented 2 years ago

My comment was applicable to your (now edited) post where you said you call .emit(message, payload)

TopCodeBeast commented 2 years ago

l did not find the solution. It's not parse # symbol error, and I found in polkadot/api/base/event.js is changed to #eventemitter = new EventEmitter(); on version 7.5

jacogr commented 2 years ago

It was changed to #eventemitter in 2020, see this PR with the specific line - https://github.com/polkadot-js/api/pull/1921/files#diff-c2509fbc77b421e64bcdb8df56a4b5f06a093d511d305a4b5eda99c4173eb00eR10 (as per the git blame for the specific file)

Assuming it is private fields the best I can suggest is searching google for "private fields with bundler" (where <bundler> is your specific bundler, e.g. webpack, parcel, etc.).

For instance here is a WP4 project that bundles the API 7.5.1 properly (via babel + browserslist in package.json to enable the env plugin to do it's job) https://github.com/jacogr/api-test-4500-wp4 and here is one that does the same in WP5 https://github.com/jacogr/api-test-4500

TopCodeBeast commented 2 years ago

cloud you tell me about vue-webpack 4 to solve that error?

TopCodeBeast commented 2 years ago

thanks I fixed

polkadot-js-bot commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.