-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ refactor: lift dependency injection to main and add documentation f…
…or its role - Moved dependency injection from `MyApp` to `main` to align with Onion Architecture principles. - Updated `MyApp` to receive injected dependencies through its constructor. - Added Dartdoc to the `main` function explaining its role as the entry point and dependency injector in the outermost circle of the architecture. Signed-off-by: Dmytro Turskyi <[email protected]>
- Loading branch information
Showing
7 changed files
with
74 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ app.*.map.json | |
/android/app/debug | ||
/android/app/profile | ||
/android/app/release | ||
/coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import 'package:counter_with_onion_architecture/core/application_services/counter_presenter.dart'; | ||
import 'package:counter_with_onion_architecture/core/domain/services/increment_counter.dart'; | ||
import 'package:counter_with_onion_architecture/core/domain/services/increment_counter_fake_impl.dart'; | ||
import 'package:counter_with_onion_architecture/infrastructure/fake_counter_data_source.dart'; | ||
import 'package:counter_with_onion_architecture/user_interface/my_app.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
/// The [main] is the ultimate detail — the lowest-level policy. | ||
/// It is the initial entry point of the system. | ||
/// Nothing, other than the operating system, depends on it. | ||
/// It is in this [main] component that dependencies should be injected. | ||
/// The [main] is a dirty low-level module in the outermost circle of the onion | ||
/// architecture. | ||
/// Think of [main] as a plugin to the [MyApp] — a plugin that sets up the | ||
/// initial conditions and configurations, gathers all the outside resources, | ||
/// and then hands control over to the high-level policy of the [MyApp]. | ||
/// When [main] is released, it has utterly no effect on any of the other | ||
/// components in the system. They don’t know about [main], and they don’t care | ||
/// when it changes. | ||
void main() => runApp(const MyApp()); | ||
/// The [main] function represents the ultimate detail — the lowest-level policy | ||
/// in the system. | ||
/// It serves as the initial entry point of the application, and nothing, other | ||
/// than the operating system, depends on it. | ||
/// In the [main] function, dependencies are injected and configurations are | ||
/// set up. | ||
/// This makes [main] a low-level module located in the outermost circle of the | ||
/// onion architecture. | ||
/// Think of [main] as a plugin to the application — a module that gathers all | ||
/// external resources, sets initial conditions, and hands control over to the | ||
/// high-level policy represented by [MyApp]. | ||
/// Changes to [main] do not affect any other component in the system, as they | ||
/// are decoupled from it and remain unaffected by its modifications. | ||
void main() { | ||
final FakeCounterDataSource dataSource = FakeCounterDataSource(); | ||
final IncrementCounter incrementCounter = IncrementCounterFakeImpl( | ||
dataSource, | ||
); | ||
final CounterPresenter presenter = CounterPresenter(incrementCounter); | ||
runApp(MyApp(presenter: presenter)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters