-
Notifications
You must be signed in to change notification settings - Fork 250
/
bind.dart
32 lines (23 loc) · 946 Bytes
/
bind.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import '../../flutter_modular.dart';
class Bind<T> {
final T Function(Inject i) inject;
///single instance object?
final bool singleton;
///When 'true', the object is instantiated only the first time it is called.
///When 'false', the object is instantiated along with the module.
final bool lazy;
final String alias;
Bind(this.inject, {this.singleton = true, this.lazy = true, this.alias })
: assert((singleton || lazy),
r"'singleton' can't be false if 'lazy' is also false");
}
class BindInject<T> extends Bind<T> {
final T Function(Inject i) inject;
///single instance object?
final bool singleton;
///When 'true', the object is instantiated only the first time it is called.
///When 'false', the object is instantiated along with the module.
final bool lazy;
BindInject(this.inject, {this.singleton = true, this.lazy = true})
: super(inject, singleton: singleton, lazy: lazy);
}