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 1eb9666
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/core/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Action extends EventEmitter2 {
* and the result in the result callback when the action is completed.
* Does nothing if this action is currently advertised.
*
* @param {TGoal} goal - The ROSLIB.ActionGoal to send.
* @param {TGoal} goal - The action goal to send.
* @param {sendGoalResultCallback} resultCallback - The callback function when the action is completed.
* @param {sendGoalFeedbackCallback} [feedbackCallback] - The callback function when the action pulishes feedback.
* @param {sendGoalFailedCallback} [failedCallback] - The callback function when the action failed.
Expand Down Expand Up @@ -149,14 +149,12 @@ class Action extends EventEmitter2 {
* action callback with the auto-generated ID as a user-accessible input.
* Should not be called manually.
*
* @param {Object} rosbridgeRequest - The ROSLIB.ActionGoal to send.
* @param {Object} rosbridgeRequest - The action goal 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 1eb9666

Please sign in to comment.