Skip to content

Commit d10cdf7

Browse files
authored
Merge pull request #693 from Flutterando/modular_5
feat!: Add New auto-dispose, selector and setArguments [Modular 5]
2 parents 768abce + e28a849 commit d10cdf7

File tree

393 files changed

+10885
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+10885
-664
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

doc/docs/flutter_modular/dependency-injection.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 3
33
---
44

55
# Dependency Injection
@@ -174,7 +174,6 @@ run an instance destruction routine and are automatically removed from memory. H
174174

175175
- Stream/Sink (Dart Native).
176176
- ChangeNotifier/ValueNotifier (Flutter Native).
177-
- Store (Triple Pattern).
178177

179178
For registered objects that are not part of this list, we can implement a **Disposable** interface on the instance where we want to run an algorithm before dispose:
180179

@@ -189,9 +188,19 @@ class MyController implements Disposable {
189188
}
190189
```
191190

191+
The dispose of an instance can be set directly in `Bind` by implementing the `onDispose` property:
192+
193+
```dart
194+
@override
195+
final List<Bind> binds = [
196+
Bind.singleton((i) => MyBloc(), onDispose: (bloc) => bloc.close()),
197+
];
198+
```
199+
192200
:::tip TIP
193201

194-
As BLoC is based on Streams, the memory release takes effect automatically.
202+
There are pre-configured `Bind` for BLoC and Triple.
203+
See the packages [modular_bloc_bind](https://pub.dev/packages/modular_bloc_bind) and [modular_triple_bind](https://pub.dev/packages/modular_triple_bind)
195204

196205
:::
197206

0 commit comments

Comments
 (0)