Skip to content

Commit a6e738b

Browse files
committed
upgrade to eventemitter3 to avoid eventemitter2 module issues
1 parent d2da4fd commit a6e738b

File tree

11 files changed

+41
-60
lines changed

11 files changed

+41
-60
lines changed

package-lock.json

Lines changed: 21 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"dependencies": {
4242
"@xmldom/xmldom": "^0.8.0",
4343
"cbor-js": "^0.1.0",
44-
"eventemitter2": "^6.4.0",
44+
"eventemitter3": "^5.0.1",
4545
"object-assign": "^4.0.0",
4646
"pngparse": "^2.0.0",
4747
"webworkify": "^1.5.0",

src/actionlib/ActionClient.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import Topic from '../core/Topic.js';
77
import Message from '../core/Message.js';
88
import Ros from '../core/Ros.js';
9-
// workaround for EventEmitter2 module issues
10-
import pkg from 'eventemitter2';
11-
const {EventEmitter2} = pkg;
9+
import {EventEmitter} from 'eventemitter3';
1210

1311
/**
1412
* An actionlib action client.
@@ -20,7 +18,7 @@ const {EventEmitter2} = pkg;
2018
* * 'result' - The result returned from the action server.
2119
*
2220
*/
23-
export default class ActionClient extends EventEmitter2 {
21+
export default class ActionClient extends EventEmitter {
2422
/**
2523
* @param {Object} options
2624
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.

src/actionlib/ActionListener.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
import Topic from '../core/Topic.js';
88
import Ros from '../core/Ros.js';
9-
// workaround for EventEmitter2 module issues
10-
import pkg from 'eventemitter2';
11-
const {EventEmitter2} = pkg;
9+
import {EventEmitter} from 'eventemitter3';
1210

1311
/**
1412
* An actionlib action listener.
@@ -20,7 +18,7 @@ const {EventEmitter2} = pkg;
2018
*
2119
2220
*/
23-
export default class ActionListener extends EventEmitter2 {
21+
export default class ActionListener extends EventEmitter {
2422
/**
2523
* @param {Object} options
2624
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.

src/actionlib/Goal.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
* @author Russell Toris - rctoris@wpi.edu
44
*/
55

6-
// workaround for EventEmitter2 module issues
7-
import pkg from 'eventemitter2';
8-
const {EventEmitter2} = pkg;
6+
import { EventEmitter } from 'eventemitter3';
97
import Message from '../core/Message.js';
108
import ActionClient from './ActionClient.js';
119

@@ -15,7 +13,7 @@ import ActionClient from './ActionClient.js';
1513
* Emits the following events:
1614
* * 'timeout' - If a timeout occurred while sending a goal.
1715
*/
18-
export default class Goal extends EventEmitter2 {
16+
export default class Goal extends EventEmitter {
1917
/**
2018
* @param {Object} options
2119
* @param {ActionClient} options.actionClient - The ROSLIB.ActionClient to use with this goal.

src/actionlib/SimpleActionServer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import Topic from '../core/Topic.js';
77
import Message from '../core/Message.js';
88
import Ros from '../core/Ros.js';
9-
// workaround for EventEmitter2 module issues
10-
import pkg from 'eventemitter2';
11-
const {EventEmitter2} = pkg;
9+
import {EventEmitter} from 'eventemitter3';
1210

1311
/**
1412
* An actionlib action server client.
@@ -17,7 +15,7 @@ const {EventEmitter2} = pkg;
1715
* * 'goal' - Goal sent by action client.
1816
* * 'cancel' - Action client has canceled the request.
1917
*/
20-
export default class SimpleActionServer extends EventEmitter2 {
18+
export default class SimpleActionServer extends EventEmitter {
2119
/**
2220
* @param {Object} options
2321
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.

src/core/Action.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
* @author Sebastian Castro - sebastian.castro@picknik.ai
44
*/
55

6-
// workaround for EventEmitter2 module issues
7-
import pkg from 'eventemitter2';
8-
const {EventEmitter2} = pkg;
6+
import {EventEmitter} from 'eventemitter3';
97
import Ros from '../core/Ros.js';
108

119
/**
1210
* A ROS 2 action client.
1311
* @template TGoal, TFeedback, TResult
1412
*/
15-
export default class Action extends EventEmitter2 {
13+
export default class Action extends EventEmitter {
1614
/**
1715
* @param {Object} options
1816
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.

src/core/Ros.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import Param from './Param.js';
1616
import TFClient from '../tf/TFClient.js';
1717
import ActionClient from '../actionlib/ActionClient.js';
1818
import SimpleActionServer from '../actionlib/SimpleActionServer.js';
19-
// workaround for EventEmitter2 module issues
20-
import pkg from 'eventemitter2';
21-
const {EventEmitter2} = pkg;
19+
import { EventEmitter } from 'eventemitter3';
2220

2321
/**
2422
* Manages connection to the server and all interactions with ROS.
@@ -30,7 +28,7 @@ const {EventEmitter2} = pkg;
3028
* * <topicName> - A message came from rosbridge with the given topic name.
3129
* * <serviceID> - A service response came from rosbridge with the given ID.
3230
*/
33-
export default class Ros extends EventEmitter2 {
31+
export default class Ros extends EventEmitter {
3432
/**
3533
* @param {Object} [options]
3634
* @param {string} [options.url] - The WebSocket URL for rosbridge. Can be specified later with `connect`.
@@ -57,9 +55,6 @@ export default class Ros extends EventEmitter2 {
5755
this.groovyCompatibility = options.groovyCompatibility;
5856
}
5957

60-
// Sets unlimited event listeners.
61-
this.setMaxListeners(0);
62-
6358
// begin by checking if a URL was given
6459
if (options.url) {
6560
this.connect(options.url);

src/core/Service.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
import ServiceResponse from './ServiceResponse.js';
77
import ServiceRequest from './ServiceRequest.js';
88
import Ros from './Ros.js';
9-
// workaround for EventEmitter2 module issues
10-
import pkg from 'eventemitter2';
11-
const {EventEmitter2} = pkg;
9+
import {EventEmitter} from 'eventemitter3';
1210

1311
/**
1412
* A ROS service client.
1513
* @template TRequest, TResponse
1614
*/
17-
export default class Service extends EventEmitter2 {
15+
export default class Service extends EventEmitter {
1816
/**
1917
* @param {Object} options
2018
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.

src/core/Topic.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
* @author Brandon Alexander - baalexander@gmail.com
44
*/
55

6-
// workaround for EventEmitter2 module issues
7-
import pkg from 'eventemitter2';
8-
const {EventEmitter2} = pkg;
6+
import { EventEmitter } from 'eventemitter3';
97
import Message from './Message.js';
108
import Ros from './Ros.js';
119

@@ -17,7 +15,7 @@ import Ros from './Ros.js';
1715
* * 'message' - The message data from rosbridge.
1816
* @template T
1917
*/
20-
export default class Topic extends EventEmitter2 {
18+
export default class Topic extends EventEmitter {
2119
/**
2220
* @param {Object} options
2321
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.
@@ -132,7 +130,7 @@ export default class Topic extends EventEmitter2 {
132130
* and remove all subscribe callbacks. To remove a callback, you must
133131
* explicitly pass the callback function in.
134132
*
135-
* @param {import('eventemitter2').ListenerFn} [callback] - The callback to unregister, if
133+
* @param {import('eventemitter3').EventEmitter.ListenerFn} [callback] - The callback to unregister, if
136134
* provided and other listeners are registered the topic won't
137135
* unsubscribe, just stop emitting to the passed listener.
138136
*/

src/tf/TFClient.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ import Topic from '../core/Topic.js';
1313
import Transform from '../math/Transform.js';
1414

1515
import Ros from '../core/Ros.js';
16-
// workaround for EventEmitter2 module issues
17-
import pkg from 'eventemitter2';
18-
const {EventEmitter2} = pkg;
16+
import { EventEmitter } from 'eventemitter3';
1917

2018
/**
2119
* A TF Client that listens to TFs from tf2_web_republisher.
2220
*/
23-
export default class TFClient extends EventEmitter2 {
21+
export default class TFClient extends EventEmitter {
2422
/**
2523
* @param {Object} options
2624
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.

0 commit comments

Comments
 (0)