public void Notify(object action) { if (action == null) { throw new ArgumentNullException(nameof(action)); } SpinLock.ExecuteLocked(() => { IEnumerable <Action <object> > callbacks = SubscriptionsForType .Where(x => x.Key.IsAssignableFrom(action.GetType())) .SelectMany(x => x.Value) .Select(x => x.Callback); foreach (Action <object> callback in callbacks) { callback(action); } }); }
/// <see cref="IMiddleware.AfterDispatch(object)"/> public override void AfterDispatch(object action) { SpinLock.ExecuteLocked(() => { IDictionary <string, object> state = GetState(); TailTask = TailTask .ContinueWith(_ => ReduxDevToolsInterop.DispatchAsync(action, state)).Unwrap(); }); // As actions can only be executed if not in a historical state (yes, "a" historical, pronounce your H!) // ensure the latest is incremented, and the current = latest SequenceNumberOfLatestState++; SequenceNumberOfCurrentState = SequenceNumberOfLatestState; }