Пример #1
0
 public ServiceCollectionAdapter <T, TVM> From(IStateCollectionReader <T> source)
 {
     Source = source;
     return(this);
 }
Пример #2
0
 public ItemsService()
 {
     TodoItems = _store.CreateReader(this, m => m.TodoItems);
 }
Пример #3
0
 /// <summary>
 /// Subscribes to a StateCollectionReader and exposes it as collection of (immuable) list values
 /// </summary>
 public static IObservable <ImmutableList <T> > ObserveValues <T, TOwner>(this IStateCollectionReader <T> source, TOwner owner)
     where TOwner : INotifyDisposable
 {
     return(source.ObserveChanges(owner).Select(changeSet => changeSet.NewValues.ToImmutableList()));
 }
Пример #4
0
 /// <summary>
 /// Subscribes to a StateCollectionReader and exposes it as an observable of DiffResult. Note that each IChange
 /// is converted into a single DiffResult, so one StateCollectionReader Change event may yield many DiffResult instances.
 /// You can use the result of this method to apply changes onto an observable collection
 /// </summary>
 public static IObservable <DiffResults <T> > ObserveDiffs <T, TOwner>(this IStateCollectionReader <T> source, TOwner owner)
     where TOwner : INotifyDisposable
 {
     return(source.ObserveChanges(owner).ToDiffResult());
 }
Пример #5
0
        /// <summary>
        /// Subscribes to an IStateCollectionReader and exposes it as Observable of CollectionChanges
        /// </summary>
        public static IObservable <CollectionChanges <T> > ObserveChanges <T, TOwner>(this IStateCollectionReader <T> source, TOwner owner)
            where TOwner : INotifyDisposable
        {
            return(Observable.Create <CollectionChanges <T> >(async observer =>
            {
                Func <CollectionChanges <T>, Task> handler = val =>
                {
                    observer.OnNext(val);
                    return Task.CompletedTask;
                };

                await source.Changed.Subscribe(owner, handler);
                return Disposables.Call(() =>
                {
                    source.Changed.Unsubscribe(owner, handler);
                });
            }));
        }