import 'package:flutter/foundation.dart';
import 'package:netrain_flutter_app/douwen/custom/http/base/IEntity.dart';

mixin IRepository {
  void getResult<T>(Future<IEntity> future,{@required T analysis(dynamic data),@required void onSuccess(T t),void onError(IEntity iEntity),void onFinally()}) async {
    IEntity iEntity = await future;
    if (iEntity.isSuccess()) {
      onSuccess(analysis(iEntity.data));
    } else {
      onError?.call(iEntity);
    }
    onFinally?.call();
  }
}