onConnectionStatusChange method

dynamic onConnectionStatusChange(
  1. dynamic fn(
    1. String status
    ), [
  2. int timetout = 5
])

Implementation

onConnectionStatusChange(Function(String status) fn, [int timetout = 5]) {
  recursive() async {
    var status = 'ok';
    try {
      await request('/login/ready');
    } catch (e) {
      status = 'offline';
    }
    fn(status);
    Future.delayed(Duration(seconds: timetout), recursive);
  }

  recursive();
}