Skip to content

Commit

Permalink
Merged main view model
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandPheasant committed Nov 17, 2015
2 parents e755dd0 + 7f1b8c2 commit a7539d0
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Source/TailBlazer/Views/FileTailerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@ public FileTailerViewModel(ILogger logger,ISchedulerProvider schedulerProvider,
if (schedulerProvider == null) throw new ArgumentNullException(nameof(schedulerProvider));
if (fileInfo == null) throw new ArgumentNullException(nameof(fileInfo));


//user entered filter
var filterRequest = this.WhenValueChanged(vm => vm.SearchText).Throttle(TimeSpan.FromMilliseconds(125));

//define scroll to observable
var autoChanged = this.WhenValueChanged(vm => vm.AutoTail);
var scroller = _userScrollRequested.CombineLatest(autoChanged, (user, auto) =>
var scroller = _userScrollRequested
.CombineLatest(autoChanged, (user, auto) =>
{
var mode = auto ? ScrollingMode.Tail : ScrollingMode.User;
var mode = AutoTail ? ScrollingMode.Tail : ScrollingMode.User;
return new ScrollRequest(mode, user.PageSize, user.FirstIndex);
})
.Sample(TimeSpan.FromMilliseconds(125))
.Sample(TimeSpan.FromMilliseconds(150))
.DistinctUntilChanged();

//construct tailer
var tailer = new FileTailer(fileInfo, filterRequest, scroller);


Expand Down Expand Up @@ -95,7 +91,6 @@ void IScrollReceiver.ScrollTo(ScrollBoundsArgs boundsArgs)
if (boundsArgs == null) throw new ArgumentNullException(nameof(boundsArgs));
var mode = AutoTail ? ScrollingMode.Tail : ScrollingMode.User;

//TODO: get rid of subject (alas each time I have tried to get rid of it, scrolling has been messed up!)
_userScrollRequested.OnNext(new ScrollRequest(mode, boundsArgs.PageSize,boundsArgs.FirstIndex));
PageSize = boundsArgs.PageSize;
FirstIndex = boundsArgs.FirstIndex;
Expand Down

0 comments on commit a7539d0

Please sign in to comment.