Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.0.0-dev

* DependencyFactory for initialize DependencyContainer

## 4.0.0

* Big Refactoring
Expand Down
165 changes: 165 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Migration
---

## [v4 to v5](#from-version-4-to-version-5)
## [v3 to v4](#from-version-3-to-version-4)

---

## From Version 4 to Version 5

### Version 5:

```dart
class RootFactory extends DependencyFactory<RootDependency> {
@override
Future<RootDependency> create() async {
return RootDependency(
apiService: await ApiService().init(),
);
}
}
```

```dart
class RootDependency extends DependencyContainer {
final AuthRepository authRepository;

ModuleDependency({required super.authRepository});

void dispose() {
// authRepository.dispose();
}
}
```

```dart
DependencyScope<RootDependency, RootFactory>(
factory: RootFactory(),
placeholder: const Center(child: CircularProgressIndicator()),
builder: (context) => const YourWidget(),
);
```


```dart
final rootDependency = await RootFactory().create();

DependencyProvider<RootDependency>(
dependency: rootDependency,
child: const YourWidget(),
);
```



### Version 4:

```dart
DependencyScope<RootDependency>(
dependency: RootDependency(),
placeholder: const Center(child: CircularProgressIndicator()),
builder: (context) => const YourWidget(),
);
```

```dart
class ModuleDependency extends DependencyContainer<RootDependency> {
late final AuthRepository authRepository;

ModuleDependency({required super.parent});

@override
Future<void> init() async {
authRepository = AuthRepository(
apiService: parent.apiService,
);
}

void dispose() {
// authRepository.dispose();
}
}
```

```dart
DependencyProvider.of<ModuleDependency>(context);
DependencyProvider.maybeOf<ModuleDependency>(context);
// or
context.depend<ModuleDependency>();
context.dependMaybe<ModuleDependency>();
```

---

## From Version 3 to Version 4

### Version 3:

```dart
InjectionScope<RootLibrary>(
library: RootLibrary(),
placeholder: const Center(child: CircularProgressIndicator()),
child: const YourWidget(),
);
```

```dart
class RootInjection extends Injection {
late final ApiService apiService;

@override
Future<void> init() async {
apiService = await ApiService().init();
}
}
```

```dart
InjectionScope.of<ModuleInjection>(context);
```

### Version 4:

```dart
DependencyScope<RootDependency>(
dependency: RootDependency(),
placeholder: const Center(child: CircularProgressIndicator()),
builder: (context) => const YourWidget(),
);
```

```dart
class ModuleDependency extends DependencyContainer<RootDependency> {
late final AuthRepository authRepository;

ModuleDependency({required super.parent});

@override
Future<void> init() async {
authRepository = AuthRepository(
apiService: parent.apiService,
);
}

void dispose() {
// authRepository.dispose();
}
}
```

```dart
DependencyProvider.of<ModuleDependency>(context);
DependencyProvider.maybeOf<ModuleDependency>(context);
// or
context.depend<ModuleDependency>();
context.dependMaybe<ModuleDependency>();
```


#### Key Differences:
- `InjectionScope` → `DependencyScope`
- `Injection` → `DependencyContainer`
- `InjectionScope` → `DependencyProvider`

---
Loading
Loading