dispatch method
Dispatches an action to the other side (main app or overlay).
On the overlay side, if the main app is disconnected, the action is queued and will be sent when the connection is restored.
Implementation
Future<void> dispatch(FloatyAction action) {
// On the overlay side, queue if disconnected.
if (_isOverlay && !FloatyConnectionState.isMainAppConnected) {
_enqueue(action);
return Future<void>.value();
}
return FloatyChannel.sendSystem(_prefix, {
'type': action.type,
'payload': action.toJson(),
});
}