public NotificationActor(Time.UpdateTimeAction onUpdateTimeRequested, Cycle.CycleChangedAction onCycleChanged) { _onUpdateTimeRequested = onUpdateTimeRequested; _onCycleChanged = onCycleChanged; Receive <NotifyTimeChanged>(message => { _onUpdateTimeRequested(message.RemainingTime, message.InitialDuration); }); Receive <NotifyCycleChanged>(message => { _onCycleChanged(message.CycleNumber, message.CycleType); }); }
public CoreSystem() { _actorSystem = ActorSystem.Create("BeEfficientPomodoro"); Time = new Subject <Time>(); Cycle = new Subject <Cycle>(); Time.UpdateTimeAction updateStateAction = (remainingtime, initialDuration) => Time.OnNext(new Time(remainingtime, initialDuration)); Cycle.CycleChangedAction cycleChangedAction = (cycleNumber, cycleType) => Cycle.OnNext(new Cycle(cycleNumber, cycleType)); Props notificationActor = Props.Create(() => new NotificationActor(updateStateAction, cycleChangedAction)); _notificationActor = _actorSystem.ActorOf(notificationActor, "notificationActor"); Props timeCoordinatorActorProps = Props.Create(() => new TimeCoordinatorActor(_notificationActor)); _timeCoordinator = _actorSystem.ActorOf(timeCoordinatorActorProps, "timeCoordinator"); }