import 'package:fis_common/extensions/type.dart';
import 'services/storage.dart';

export 'services/storage.dart';

///WebAPI的代理
class WebApiProxy {
  final _instancesMap = <Type, dynamic>{};

  StorageWebApi get storage => _findInstance(() => StorageWebApi());

  T _findInstance<T>(T Function() builder) {
    Type type = typeOf<T>();
    if (_instancesMap.containsKey(type)) {
      return _instancesMap[T];
    }
    final instance = builder.call();
    _instancesMap[type] = instance;
    return instance;
  }
}
