Skip to content

Commit 1eb9666

Browse files
committed
Check data type for action callback
1 parent afa5e4a commit 1eb9666

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/core/Action.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Action extends EventEmitter2 {
4545
* and the result in the result callback when the action is completed.
4646
* Does nothing if this action is currently advertised.
4747
*
48-
* @param {TGoal} goal - The ROSLIB.ActionGoal to send.
48+
* @param {TGoal} goal - The action goal to send.
4949
* @param {sendGoalResultCallback} resultCallback - The callback function when the action is completed.
5050
* @param {sendGoalFeedbackCallback} [feedbackCallback] - The callback function when the action pulishes feedback.
5151
* @param {sendGoalFailedCallback} [failedCallback] - The callback function when the action failed.
@@ -149,14 +149,12 @@ class Action extends EventEmitter2 {
149149
* action callback with the auto-generated ID as a user-accessible input.
150150
* Should not be called manually.
151151
*
152-
* @param {Object} rosbridgeRequest - The ROSLIB.ActionGoal to send.
152+
* @param {Object} rosbridgeRequest - The action goal to send.
153153
* @param {string} rosbridgeRequest.id - The ID of the action goal.
154+
* @param {TGoal} rosbridgeRequest.args - The arguments of the action goal.
154155
*/
155156
_executeAction(rosbridgeRequest) {
156-
var id;
157-
if (rosbridgeRequest.id) {
158-
id = rosbridgeRequest.id;
159-
}
157+
var id = rosbridgeRequest.id;
160158

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

170-
// Call the goal execution function provided.
171-
// @ts-expect-error -- possibly null
172-
this._actionCallback(rosbridgeRequest.args, id);
168+
// Call the action goal execution function provided.
169+
if (typeof this._actionCallback === 'function')
170+
{
171+
this._actionCallback(rosbridgeRequest.args, id);
172+
}
173173
}
174174

175175
/**

0 commit comments

Comments
 (0)