public virtual void Initialize() { _guid = Guid.NewGuid(); this.errorSubject = new Subject <IReactiveDbContextEventArgs>(); this.errorObservable = errorSubject.Publish().RefCount(); this.errorCountable = new Countable(); this.errorObservable = this.errorCountable.GetCountable(this.errorObservable); this.validationErrorSubject = new Subject <ValidationEntitiesException>(); this.validationErrorObservable = validationErrorSubject.Publish().RefCount(); this.validationErrorCountable = new Countable(); this.validationErrorObservable = this.validationErrorCountable.GetCountable(this.validationErrorObservable); }
/// <summary> /// Initializes a new instance of the <see cref="ExtensionState{TSender}"/> class. /// </summary> public ExtensionState(IReactiveDbObject sender) { this.sender = sender; this.addingSubject = new Subject <IReactiveDbObjectEventArgs>(); this.addedSubject = new Subject <IReactiveDbObjectEventArgs>(); this.updatingSubject = new Subject <IReactiveDbObjectEventArgs>(); this.updatedSubject = new Subject <IReactiveDbObjectEventArgs>(); this.deletingSubject = new Subject <IReactiveDbObjectEventArgs>(); this.deletedSubject = new Subject <IReactiveDbObjectEventArgs>(); this.errorSubject = new Subject <IReactiveDbObjectEventArgs>(); this.validationErrorSubject = new Subject <ValidationEntityEventArg>(); this.startDelayNotifications = new Subject <Unit>(); this.thrownExceptions = new ScheduledSubject <Exception>(Scheduler.Immediate, ExceptionHandler.Default); /* this.addedObservable = createObservable(ref addedSubject); * this.addingObservable = createObservable(ref addingSubject); * this.updatedObservable = createObservable(ref updatedSubject); * this.updatingObservable = createObservable(ref updatingSubject); * this.deletedObservable = createObservable(ref deletedSubject); * this.deletingObservable = createObservable(ref deletingSubject);*/ this.addedObservable = addedSubject .Buffer( Observable.Merge( addedSubject.Where(_ => !areChangeNotificationsDelayed()).Select(_ => Unit.Default), startDelayNotifications) ) .SelectMany(batch => dedup(batch)) .Publish() .RefCount(); this.addingObservable = addingSubject .Buffer( Observable.Merge( addingSubject.Where(_ => !areChangeNotificationsDelayed()).Select(_ => Unit.Default), startDelayNotifications) ) .SelectMany(batch => dedup(batch)) .Publish() .RefCount(); this.updatedObservable = updatedSubject .Buffer( Observable.Merge( updatedSubject.Where(_ => !areChangeNotificationsDelayed()).Select(_ => Unit.Default), startDelayNotifications) ) .SelectMany(batch => dedup(batch)) .Publish() .RefCount(); this.updatingObservable = updatingSubject .Buffer( Observable.Merge( updatingSubject.Where(_ => !areChangeNotificationsDelayed()).Select(_ => Unit.Default), startDelayNotifications) ) .SelectMany(batch => dedup(batch)) .Publish() .RefCount(); this.deletedObservable = deletedSubject .Buffer( Observable.Merge( deletedSubject.Where(_ => !areChangeNotificationsDelayed()).Select(_ => Unit.Default), startDelayNotifications) ) .SelectMany(batch => dedup(batch)) .Publish() .RefCount(); this.deletingObservable = deletingSubject .Buffer( Observable.Merge( deletingSubject.Where(_ => !areChangeNotificationsDelayed()).Select(_ => Unit.Default), startDelayNotifications) ) .SelectMany(batch => dedup(batch)) .Publish() .RefCount(); this.errorObservable = errorSubject .Buffer( Observable.Merge( errorSubject.Where(_ => !areChangeNotificationsDelayed()).Select(_ => Unit.Default), startDelayNotifications) ) .SelectMany(batch => dedup(batch)) .Publish() .RefCount(); this.errorCountable = new Countable(); this.errorObservable = this.errorCountable.GetCountable(this.errorObservable); this.validationErrorObservable = validationErrorSubject .Publish() .RefCount(); this.validationErrorCountable = new Countable(); this.validationErrorObservable = this.validationErrorCountable.GetCountable(this.validationErrorObservable); }