single_base 1.0.1+3 copy "single_base: ^1.0.1+3" to clipboard
single_base: ^1.0.1+3 copied to clipboard

discontinued
outdated

Platform agnostic bloc and storage interfaces that don't depend on any framework.

single_base #

Platform agnostic bloc and storage interfaces for dart.

Provides interfaces for:

  • Disposable Blocs:
class ExampleBloc implements BlocBase {
  const ExampleBloc();

  @override
  Future<void> dispose() async {
  }
}
  • Initializable Blocs:
class ExampleBlocWithInit implements InitializableBlocBase {
  const ExampleBlocWithInit();

  @override
  Future<void> dispose() async {
  }

  @override
  Future<void> init() async {
  }
}
  • Disposable & Initializable Blocs:
class ExampleBaggedBloc extends BaggedInitializableBlocBase {
  ExampleBaggedBloc(Iterable<BlocBase> blocs,
      Iterable<InitializableBlocBase> initializableBlocs) {
    blocs.forEach(bagBloc);
    initializableBlocs.forEach(bagState);
    disposeLater(() => print("dispose me later"));
    initLater(() => print("init me later"));
  }
}
  • Hook Blocs that give you the ability to schedule objects for disposal in one line during their initialization:

class ExampleHookBloc extends HookBloc {
  final MyOtherBloc otherBloc = MyOtherBloc(onInit: HookBloc.disposeBloc);
}

class MyOtherBloc extends BlocBase {
  MyOtherBloc({void Function(BlocBase) onInit}) {
    onInit(this);
  }
}
  • Platform agnostic storage base class:
class MyStorage extends StorageBase<String> {
  @override
  Future<bool> exists(String key) async {
    return false;
  }

  @override
  Future<String> get(String key) async {
    return "todo";
  }

  @override
  String location(String key) {
    return key;
  }

  @override
  Future<void> remove(String key) async {
    // remove
  }

  @override
  Future<void> set(String key, String value) async {
    // set
  }
}

final storage = MyStorage();
final storageAt = storage.at("somewhere");
final storageSomewhereElse = storage.map((key) => "somewhere/$key");
0
likes
40
pub points
0%
popularity

Publisher

verified publishermodulovalue.com

Platform agnostic bloc and storage interfaces that don't depend on any framework.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

meta

More

Packages that depend on single_base