public IDisposable Connect(IReactTo <IRxn> reaction, IScheduler inputScheduler = null) { var resource = RxnCreator.AttachReaction(reaction, typeof(IRxn), this, inputScheduler); var health = AttachHealthMonitorIf(reaction); _molecules.Add(reaction); OnInformation("Connected to reaction '{0}'", reaction.GetType()); return(new CompositeDisposable(resource, new DisposableAction(() => { if (health != null) { health.Dispose(); } OnInformation("Disconnected reaction '{0}'", reaction.GetType()); _molecules.Remove(reaction); })) .DisposedBy(_resources)); }
/// <summary> /// Sets up a new reaction pipeline. Typically this is followed by an action to be taken /// when TStuff occours /// /// advanced: its a simple fluent wrapper for Input.ObserveOn /// </summary> /// <typeparam name="TStuff"></typeparam> /// <param name="context">The reaction component</param> /// <param name="scheduler">The scheduler tha the pipeline will use for work. Defaults to OnReactionScheduler</param> public static IObservable <TStuff> OnReactionTo <TStuff>(this IReactTo <IRxn> context, IScheduler scheduler = null) { return(context.Input.ObserveOn(scheduler ?? OnReactionScheduler).OfType <TStuff>()); }