fang 0.0.2 copy "fang: ^0.0.2" to clipboard
fang: ^0.0.2 copied to clipboard

A lightweight, zero-boilerplate service locator for Dart. Originally built for nyxx bot development.

example/fang_example.dart

import 'dart:async';
import 'dart:io';

import 'package:fang/fang.dart';


final class CustomClient {

  const CustomClient();

  String doA() => 'a';

  Future<int> doB() => Future<int>.value(2);

}


Future<void> main(final List<String> args) async {

  /// Imagine we have a client for something (http, database, device ...)
  const CustomClient customClient = CustomClient();

  /// We hold it between our fangs
  Fang.bite(customClient);

  /// Calling the singleton from Fang from somewhere else
  Timer.run(() async {
    print(await Fang.hunt<CustomClient>().doB());
    exit(0);
  });
}
1
likes
150
points
33
downloads

Documentation

API reference

Publisher

verified publisherprojetretro.io

Weekly Downloads

A lightweight, zero-boilerplate service locator for Dart. Originally built for nyxx bot development.

Repository

License

unknown (license)

Dependencies

meta

More

Packages that depend on fang