public void Dispose()
        {
            TextInput?.Dispose();
            FirstCharacter?.Dispose();
            StringLength?.Dispose();
            StringLengthLabel?.Dispose();
            FirstCharacterLabel?.Dispose();

            TimeOnPage?.Dispose();
            TimeOnPageLabel?.Dispose();
        }
        public ReactiveSampleViewModel()
        {
            TextInput           = new ReactiveProperty <string>("");
            FirstCharacter      = TextInput.Select(x => x.ToCharArray()).Select(x => x.Any() ? (char?)x.First() : null).ToReadOnlyReactiveProperty();
            FirstCharacterLabel = FirstCharacter.Select(x => x != null ? $"The first character is {x.ToString()}" : "There is no first character!").ToReadOnlyReactiveProperty();
            StringLength        = TextInput.Select(x => x.Length).ToReadOnlyReactiveProperty();
            StringLengthLabel   = StringLength.Select(x => $"The string is {x} character{(x != 1 ? "s" : "")} long.").ToReadOnlyReactiveProperty();

            var timePageLoaded = DateTime.Now;

            TimeOnPage      = Observable.Interval(TimeSpan.FromSeconds(1)).Select(x => DateTime.Now.Subtract(timePageLoaded)).ToReadOnlyReactiveProperty();
            TimeOnPageLabel = TimeOnPage.Select(x => (int)x.TotalSeconds).Select(x => $"You've been on this page for {x} second{(x != 1 ? "s" : "")}.").ToReadOnlyReactiveProperty();
        }
Beispiel #3
0
 public void Add(TimeOnPage timeOnPage)
 {
     _context.TimesOnPages.Add(timeOnPage);
     _context.SaveChanges();
 }