Extract EngineService into separate service
This commit is contained in:
parent
04d61bfa02
commit
a92b864dfa
8 changed files with 86 additions and 67 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:angular/angular.dart';
|
||||
import 'package:angular_components/angular_components.dart';
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
import 'package:rules_of_living/service/control_service.dart';
|
||||
|
||||
@Component(
|
||||
selector: 'sim-controls',
|
||||
|
|
@ -15,27 +15,27 @@ import 'package:rules_of_living/service/engine_service.dart';
|
|||
styleUrls: const ["controls_component.css"],
|
||||
)
|
||||
class ControlsComponent {
|
||||
final EngineService engine;
|
||||
final ControlService ctrl;
|
||||
|
||||
ControlsComponent(this.engine);
|
||||
ControlsComponent(this.ctrl);
|
||||
|
||||
void onStartClicked() {
|
||||
engine.toggleRunning();
|
||||
ctrl.toggleRunning();
|
||||
}
|
||||
|
||||
void onStepClicked() {
|
||||
engine.step();
|
||||
ctrl.step();
|
||||
}
|
||||
|
||||
void onResetClicked() {
|
||||
engine.reset();
|
||||
ctrl.reset();
|
||||
}
|
||||
|
||||
void onRandomClicked() {
|
||||
engine.addRandomPattern();
|
||||
ctrl.addRandomPattern();
|
||||
}
|
||||
|
||||
void onClearClicked() {
|
||||
engine.clear();
|
||||
ctrl.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:html' as html;
|
||||
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
import 'package:rules_of_living/service/control_service.dart';
|
||||
|
||||
@Component(
|
||||
selector: 'gol-simulation',
|
||||
|
|
@ -10,9 +10,9 @@ import 'package:rules_of_living/service/engine_service.dart';
|
|||
providers: [],
|
||||
)
|
||||
class SimulationComponent implements OnInit {
|
||||
final EngineService engineService;
|
||||
final ControlService ctrl;
|
||||
|
||||
SimulationComponent(this.engineService);
|
||||
SimulationComponent(this.ctrl);
|
||||
|
||||
@override
|
||||
void ngOnInit() {
|
||||
|
|
@ -29,6 +29,6 @@ class SimulationComponent implements OnInit {
|
|||
|
||||
the canvas did not load correctly :(
|
||||
''', canvas.width / 2 - 50, canvas.height / 2);
|
||||
engineService.canvas = canvas;
|
||||
ctrl.canvas = canvas;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue