angel3_container 8.1.1 copy "angel3_container: ^8.1.1" to clipboard
angel3_container: ^8.1.1 copied to clipboard

Angel3 hierarchical DI container, and pluggable backends for reflection.

Angel3 Container #

Pub Version (including pre-releases) Null Safety Gitter License

A better IoC container for Angel3, ultimately allowing Angel3 to be used with or without dart:mirrors package.

    import 'package:angel3_container/mirrors.dart';
    import 'package:angel3_framework/angel3_framework.dart';
    import 'package:angel3_framework/http.dart';

    @Expose('/sales', middleware: [process1])
    class SalesController extends Controller {
        @Expose('/', middleware: [process2])
        Future<String> route1(RequestContext req, ResponseContext res) async {
            return "Sales route";
        }
    }

    bool process1(RequestContext req, ResponseContext res) {
        res.write('Hello, ');
        return true;
    }

    bool process2(RequestContext req, ResponseContext res) {
        res.write('From Sales, ');
        return true;
    }

    void main() async {
        // Using Mirror Reflector
        var app = Angel(reflector: MirrorsReflector());

        // Sales Controller
        app.container.registerSingleton<SalesController>(SalesController());
        await app.mountController<SalesController>();

        var http = AngelHttp(app);
        var server = await http.startServer('localhost', 3000);
        print("Angel3 server listening at ${http.uri}");
    }
0
likes
160
pub points
49%
popularity

Publisher

verified publisherdukefirehawk.com

Angel3 hierarchical DI container, and pluggable backends for reflection.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

collection, quiver

More

Packages that depend on angel3_container