public TimeEntriesDataSource(
            IRepository <IDatabaseTimeEntry> repository,
            ITimeService timeService)
            : base(repository)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));

            this.timeService = timeService;

            CurrentlyRunningTimeEntry =
                GetAll(te => te.IsDeleted == false && te.Duration == null)
                .Select(tes => tes.SingleOrDefault())
                .StartWith()
                .Merge(Created.Where(te => te.IsRunning()))
                .Merge(Updated.Where(update => update.Id == currentlyRunningTimeEntryId).Select(update => update.Entity))
                .Merge(Deleted.Where(id => id == currentlyRunningTimeEntryId).Select(_ => null as IThreadSafeTimeEntry))
                .Select(runningTimeEntry)
                .ConnectedReplay();

            IsEmpty =
                Observable.Return(default(IDatabaseTimeEntry))
                .StartWith()
                .Merge(Updated.Select(tuple => tuple.Entity))
                .Merge(Created)
                .SelectMany(_ => GetAll(te => te.IsDeleted == false))
                .Select(timeEntries => timeEntries.None());

            RivalsResolver = new TimeEntryRivalsResolver(timeService);

            TimeEntryStarted   = timeEntryStartedSubject.AsObservable();
            TimeEntryStopped   = timeEntryStoppedSubject.AsObservable();
            SuggestionStarted  = suggestionStartedSubject.AsObservable();
            TimeEntryContinued = timeEntryContinuedSubject.AsObservable();
        }