onHeartbeat static method

StreamSubscription<Location> onHeartbeat(
  1. void callback(
    1. Location
    ), {
  2. Function? onError,
})

Subscribes to heartbeat events.

Implementation

static StreamSubscription<Location> onHeartbeat(
  void Function(Location) callback, {
  Function? onError,
}) {
  return events
      .where((event) => event.type == EventType.heartbeat)
      .map((event) => event.data)
      .where((data) => data is Location)
      .cast<Location>()
      .listen(callback, onError: onError);
}