How to get callback for cocos targeted action

I have a game with cocos2d-x-3.15.1 where I have an item which I am moving. I want to get a callback called when the action is done. For this I have used following code structure.

ActionEase* const action = MoveTo::create(timeToStop, destinationPoint);
TargetedAction* const targetedAction = TargetedAction::create(item, action);
CallFunc* const dispatchEvent = CallFunc::create([this]()
                                                       {
                                                           _eventDispatcher->dispatchCustomEvent(EVENT);
                                                        });
auto itemsMoveAction = Sequence::createWithTwoActions(targetedAction, dispatchEvent);
runAction(itemsMoveAction);

But my code, sometimes fails to execute correct and I suspect that is becouse of this https://github.com/cocos2d/cocos2d-x/issues/18046 Sequence fails to complete. #18046 bug. How can I achieve the same functionality without using Sequence?

So long as your action is a FiniteTimeAction, you could do something like this:

item->runAction(action);
auto itemsMoveAction = Sequence::createWithTwoActions(
   DelayTime::create(action->getDuration),
   dispatchEvent
);
runAction(itemsMoveAction);

Though, it’s worth noting that if the action on item is stopped, the dispatchEvent will still go off at a later time, so you would need to account for that if it’s a possibility.

Thanks @xikka for response. I wanted to completely avoid using Sequence, but it seems there is no way. I have already implemented something similar to your suggestion and now I am testing it.