Skip to content

Commit

Permalink
fix/simplify: rebuild with cascade
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender committed Aug 13, 2024
1 parent ab0f09c commit 57a929f
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 218 deletions.
6 changes: 3 additions & 3 deletions src/_common/Observables/IStreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public interface IStreamHub<in TIn, TOut>
/// All periods (inclusive) after this DateTime will be removed.
/// </param>
/// <param name="notify">
/// Send delete point to subscribers.
/// Notify subscribers of the delete point.
/// </param>
void RemoveRange(DateTime fromTimestamp, bool notify);

Expand All @@ -104,11 +104,11 @@ public interface IStreamHub<in TIn, TOut>
/// </summary>
/// <remarks>
/// For observers, if your intention is to rebuild from a provider,
/// use alternate <see cref="IStreamObserver{T}.Rebuild(int,int?)"/>.
/// use alternate <see cref="IStreamObserver{T}.Rebuild(int)"/>.
/// </remarks>
/// <param name="fromIndex">From index, inclusive</param>
/// <param name="notify">
/// Send delete point to subscribers.
/// Notify subscribers of the delete position.
/// </param>
void RemoveRange(int fromIndex, bool notify);

Expand Down
14 changes: 8 additions & 6 deletions src/_common/Observables/IStreamObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ public interface IStreamObserver<in T>
/// <param name="item">
/// The current notification information.
/// </param>
/// <param name="indexHint">Provider index hint</param>
void OnAdd(T item, int? indexHint);
/// <param name="notify">
/// Notify subsribers of the new item.
/// </param>
/// <param name="indexHint">
/// Provider index hint, if known.
/// </param>
void OnAdd(T item, bool notify, int? indexHint);

/// <summary>
/// Provides the observer with starting point in timeline
Expand Down Expand Up @@ -113,8 +118,5 @@ public interface IStreamObserver<in T>
/// All periods (inclusive) after this index position
/// will be removed and recalculated.
/// </param>
/// <param name="provIndex">
/// Matching provider index, if known.
/// </param>
void Rebuild(int fromIndex, int? provIndex = null);
void Rebuild(int fromIndex);
}
2 changes: 1 addition & 1 deletion src/_common/Observables/StreamHub.Observable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void NotifyObserversOnAdd(TOut item, int? indexHint)
// send to subscribers
foreach (IStreamObserver<TOut> o in _observers.ToArray())
{
o.OnAdd(item, indexHint);
o.OnAdd(item, notify: true, indexHint);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/_common/Observables/StreamHub.Observer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public abstract partial class StreamHub<TIn, TOut> : IStreamObserver<TIn>

// observer methods

public virtual void OnAdd(TIn item, int? indexHint)
public virtual void OnAdd(TIn item, bool notify, int? indexHint)
{
// pass-thru, usually
(TOut result, int index) = ToIndicator(item, indexHint);
AppendCache(result, index);
AppendCache(result, notify);
}

public void OnChange(DateTime fromTimestamp)
Expand Down
Loading

0 comments on commit 57a929f

Please sign in to comment.