Skip to content

Bugfix/fix scheduling operators - #32

Merged
DevJasperNL merged 7 commits into
mainfrom
bugfix/fix_scheduling_operators
Sep 3, 2026
Merged

Bugfix/fix scheduling operators#32
DevJasperNL merged 7 commits into
mainfrom
bugfix/fix_scheduling_operators

Conversation

@DevJasperNL

Copy link
Copy Markdown
Owner

No description provided.

…, LimitTrueDuration and

their False variants) are now implemented as explicit state machines that subscribe to the
source exactly once and drive a single timer on the provided IScheduler.

Fixed
- TrueForAtLeast/PersistTrueFor/LimitTrueDuration no longer depend on the source fanning out
  each value to all subscribers before producing the next one. Sources such as SelectMany
  bursts, Observable.Return(...).Concat(...) or arrays converted with ToObservable() produced
  wrong output (e.g. TrueForAtLeast emitting only "false", or releasing a "false" immediately
  instead of after the timespan).
- Deferred and other cold sources were subscribed three to four times per subscriber; they are
  now subscribed once.
- When the source completed while a timer was running, the pending value leaked immediately
  (WhenTrueFor could report "true" before the timespan had passed). Pending values are now
  dropped on completion by default; see CompletionBehavior below.
- LimitTrueDuration (distinct): a repeated "true" after the limit re-emitted "true" and never
  limited it again. It is now ignored until the source emits "false", unless
  resetTimerOnConsecutiveTrue is set, in which case it re-arms the limit.

Added
- CompletionBehavior parameter on all scheduling methods: CompleteImmediately (default) drops a
  value still pending on the timer; CompleteAfterTimer waits for the timer, emits it, then
  completes.
- distinctUntilChanged parameter on WhenTrueFor, WhenFalseFor, PersistTrueFor and
  PersistFalseFor. It follows the existing resetTimerOnConsecutive* parameter so positional
  callers keep working.
- Tests covering five source shapes (Subject, SelectMany burst, cold array, cold Concat,
  Defer+Prepend), single subscription, disposal, and both completion behaviors for every
  scheduling operator.

Compatibility
- Source-compatible; recompile against this version (new optional parameters change method
  signatures).
- Behavior change: values previously leaked on source completion are no longer emitted
  unless CompletionBehavior.CompleteAfterTimer is passed.
- TrueForAtLeast now returns the source unchanged for a zero or negative timespan, like
  PersistTrueFor and WhenTrueFor.
@DevJasperNL
DevJasperNL merged commit b085e99 into main Sep 3, 2026
3 checks passed
@DevJasperNL
DevJasperNL deleted the bugfix/fix_scheduling_operators branch September 3, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant