Skip to content

Commit

Permalink
Check data type for action callback
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass committed Dec 14, 2023
1 parent afa5e4a commit 7080bd9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ class Action extends EventEmitter2 {
*
* @param {Object} rosbridgeRequest - The ROSLIB.ActionGoal to send.
* @param {string} rosbridgeRequest.id - The ID of the action goal.
* @param {TGoal} rosbridgeRequest.args - The arguments of the action goal.
*/
_executeAction(rosbridgeRequest) {
var id;
if (rosbridgeRequest.id) {
id = rosbridgeRequest.id;
}
var id = rosbridgeRequest.id;

// If a cancellation callback exists, call it when a cancellation event is emitted.
if (typeof id === 'string') {
Expand All @@ -167,9 +165,11 @@ class Action extends EventEmitter2 {
});
}

// Call the goal execution function provided.
// @ts-expect-error -- possibly null
this._actionCallback(rosbridgeRequest.args, id);
// Call the action goal execution function provided.
if (typeof this._actionCallback === 'function')
{
this._actionCallback(rosbridgeRequest.args, id);
}
}

/**
Expand Down

0 comments on commit 7080bd9

Please sign in to comment.