示例#1
0
        public ObservableMvxSourceBinding(IObservable <T> source, Type sourceType, IMvxMainThreadDispatcher mainThreadDispatcher, IList <MvxPropertyToken> remainingTokens)
        {
            Contract.Requires(source != null);
            Contract.Requires(sourceType != null);

            this._sourceType = sourceType;

            if (mainThreadDispatcher != null)
            {
                source = source.ObserveOn(mainThreadDispatcher);
            }

            this._sourceSubscription = source
                                       .Subscribe(value =>
            {
                this._currentValue = value;

                if (this._currentSubBinding != null)
                {
                    this._currentSubBinding.Dispose();
                    this._currentSubBinding = null;
                }

                if (this._currentSubBindingSubscription != null)
                {
                    this._currentSubBindingSubscription.Dispose();
                    this._currentSubBindingSubscription = null;
                }

                IMvxSourceBinding newSubBinding = null;
                if ((remainingTokens != null) && (remainingTokens.Count > 0))
                {
                    newSubBinding = MvxSingleton <IMvxBindingSingletonCache> .Instance.SourceBindingFactory.CreateBinding(value, remainingTokens);
                }

                var subBindingObservable = (newSubBinding != null)
                        ? Observable
                                           .Return <object>(null)
                                           .Concat(Observable
                                                   .FromEventPattern(eh => newSubBinding.Changed += eh, eh => newSubBinding.Changed -= eh))
                                           .Select(x => newSubBinding.GetValue())
                                           .Select(x => (x as IObservable <object>) ?? Observable.Return(x))
                                           .Switch()
                        : Observable.Return <object>(null);

                this._currentSubBinding = newSubBinding;

                this._currentSubBindingSubscription = subBindingObservable.Subscribe((value2 =>
                {
                    var changed2 = this.Changed;
                    if (changed2 != null)
                    {
                        changed2(this, EventArgs.Empty);
                    }
                }));
            });
        }
示例#2
0
        public static IObservable<T> ObserveOn<T>(this IObservable<T> source, IMvxMainThreadDispatcher dispatcher)
        {
            Contract.Requires(source != null);
            Contract.Requires(dispatcher != null);

            return Observable.Create<T>(observer => source.Subscribe(
                value => dispatcher.RequestMainThreadAction(() => observer.OnNext(value)),
                ex => dispatcher.RequestMainThreadAction(() => observer.OnError(ex)),
                () => dispatcher.RequestMainThreadAction(observer.OnCompleted)));
        }
 public MvxUserInteraction(IMvxMainThreadDispatcher dispatcher)
 {
     _dispatcher     = dispatcher;
     _progressHelper = new ProgressHelper(_dispatcher);
 }
示例#4
0
 public InformationService(IMvxMainThreadDispatcher dispatcher)
 {
     this.dispatcher = dispatcher;
 }
示例#5
0
 public ChatRoomViewModel(IRealtimeDataService reatimeService, IMvxMainThreadDispatcher dispatcher) : base(reatimeService)
 {
     Messages    = new MvxObservableCollection <ChatMessageViewModel>();
     _dispatcher = dispatcher;
 }
 public MvxUserInteraction(IMvxMainThreadDispatcher dispatcher, IMvxAndroidCurrentTopActivity topActivity)
 {
     _topActivity    = topActivity;
     _dispatcher     = dispatcher;
     _progressHelper = new ProgressHelper(_dispatcher);
 }
        public ObservableMvxPropertySourceBindingFactoryExtension(IMvxMainThreadDispatcher mainThreadDispatcher)
        {
            Contract.Requires(mainThreadDispatcher != null);

            this._mainThreadDispatcher = mainThreadDispatcher;
        }
 public ProgressHelper(IMvxMainThreadDispatcher dispatcher)
 {
     _dispatcher = dispatcher;
 }
示例#9
0
 public WifiViewModel(IWifi wifi, IMvxMainThreadDispatcher dispatcher)
 {
     _wifi       = wifi;
     _dispatcher = dispatcher;
 }
        public ObservableMvxPropertySourceBindingFactoryExtension(IMvxMainThreadDispatcher mainThreadDispatcher)
        {
            Contract.Requires(mainThreadDispatcher != null);

            this._mainThreadDispatcher = mainThreadDispatcher;
        }
 public WifiViewModel(IWifi wifi, IMvxMainThreadDispatcher dispatcher)
 {
     _wifi = wifi;
     _dispatcher = dispatcher;
 }