send method

dynamic send(
  1. Future observable, {
  2. TaskStatusListener? listener,
  3. OnData? onData,
  4. OnError? onError,
})

Implementation

send(Future observable,
    {TaskStatusListener? listener, OnData? onData, OnError? onError}) {
  final ls = listener ?? EmptyListener();

  ls.onStart();

  observable.then(
    (data) {
      final canCall = () => true && onData != null;
      if (canCall()) Timer.run(() => onData?.call(data));
    },
    onError: (e, s) {
      List data = e.toString().split('::');

      if (data.length != 3) {
        return;
      }
//            errLog(e, s);
      if (onError != null) {
        Timer.run(
          () => onError(data[1], int.parse(data[0].toString())),
        );
      } else if (e is AuthError) {
//          clearLoginInfo();
//          toLogin(context, err);
      }
    },
  )..whenComplete(ls.onFinish);
}