Skip to content

feat(throttle): propose future duration signals - #7642

Draft
hansschenker wants to merge 1 commit into
ReactiveX:masterfrom
hansschenker:proposal/future-duration-signal
Draft

hansschenker wants to merge 1 commit into
ReactiveX:masterfrom
hansschenker:proposal/future-duration-signal

Conversation

@hansschenker

Copy link
Copy Markdown

Proposal

This draft adds an opt-in future-duration contract for audit-mode throttle in RxJS 9:

import { auditConfig, futureDuration, throttle } from 'rxjs/throttle';

const audited = source[throttle](
  (value) => futureDuration(durationFor(value)),
  auditConfig
);

Motivation

ObservableValue proves that a value can be converted to an Observable; it does not prove when that Observable will notify. A synchronous Observable or Iterable can therefore close an audit window in the selector's call stack and make a synchronous burst behave like pass-through rather than rate-limiting.

Design

  • add opaque FutureDurationSignal and the futureDuration(...) factory
  • add nominal auditConfig, which selects a strict throttle overload
  • use a host timeout for numeric factory inputs
  • defer conversion and activation of ObservableValue inputs to a microtask
  • keep ordinary ThrottleConfig and its full structural input boundary unchanged
  • retain D-021's single throttle Symbol rather than adding a separate audit operator

The guarantee is intentionally narrow: a branded duration cannot notify in the selector's current synchronous call stack. It does not promise eventual notification or an elapsed-time lower bound, and completion without a value keeps the existing non-emitting cleanup behavior.

Compatibility and migration

This is recorded as proposed D-060. The RxJS 7 migration adapter is deliberately unchanged: wrapping an existing immediate or empty duration is a semantic change, so automated adoption still needs an explicit policy decision.

JavaScript behavior and manually written generic throttle configurations remain compatible. The stricter contract applies only when callers opt into the exported auditConfig value.

Verification

  • 106 source test files / 754 tests
  • public TypeScript usage gate
  • package build
  • ESM and CommonJS import fixtures
  • exact public-Symbol installation audit
  • package documentation/link audit
  • package lint: 0 errors (existing warning baseline remains)
  • Prettier and git diff --check

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant