Skip to content

Commit

Permalink
♻️ refactor: Lift dependency injection from CounterPresenter to main
Browse files Browse the repository at this point in the history
- Moved dependency injection from `CounterPresenter` to `main` to align with Onion Architecture principles and improve testability.
- Updated `CounterPresenter` to receive injected dependencies through its constructor.

Signed-off-by: Dmytro Turskyi <[email protected]>
  • Loading branch information
Turskyi committed Jan 23, 2025
1 parent 2a53dcc commit fb40174
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class MyApp extends StatelessWidget {
}
void main() {
final FakeCounterDataSource dataSource = FakeCounterDataSource();
final CounterDataSource dataSource = FakeCounterDataSource();
final IncrementCounter incrementCounter = IncrementCounterFakeImpl(
dataSource,
);
Expand Down
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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/counter_data_source.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';
Expand All @@ -19,7 +20,7 @@ import 'package:flutter/material.dart';
/// 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 CounterDataSource dataSource = FakeCounterDataSource();
final IncrementCounter incrementCounter = IncrementCounterFakeImpl(
dataSource,
);
Expand Down

0 comments on commit fb40174

Please sign in to comment.