public Behaviour <A> SubscribeOn(SynchronizationContext context) { var r = new Behaviour <A>(Value); Subject.SubscribeOn(context).Subscribe(r.Subject); return(r); }
/// <summary> /// Subscribes to LiveData, if allowDuplicatesInSequenceAndOnResume flag is set, duplicates in sequence will be allowed /// and last value re-emitted on onResume event /// </summary> /// <param name="onNext">Emits only non null objects</param> /// <param name="onError"></param> /// <param name="onCompleted"></param> /// <returns>IDisposable</returns> public IDisposable Subscribe(Action <T> onNext, Action <Exception> onError, Action onCompleted) { return(_subject.SubscribeOn(_rxSchedulers.Io()) .ObserveOn(_rxSchedulers.Ui()) .Subscribe(obj => { if (obj != null && _allowDuplicatesInSequenceAndOnResumeFlag) { Value = obj; onNext.Invoke(obj); } else { if (obj != null && !obj.Equals(_lastEmitted)) { Value = obj; onNext.Invoke(obj); } _lastEmitted = obj; } }, onError, onCompleted)); }