You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DisplaceTransfer — switch-map transfer with onDisplace callback
New transfer:DisplaceTransfer<TInput, TOutput, TInner> — for each input value, creates a new inner async-pushable + subscribable transfer via a factory function, pushes the value into it via asyncPush(), and forwards the inner's emissions to outer subscribers. On each new push(), the previous inner is unsubscribed and destroyed — only the latest inner's emissions pass through. RxJS equivalent:switchMap.
New factory:createDisplaceTransfer<TInput, TOutput, TInner>().
Documentation
README — DisplaceTransfer section: New subsection with capabilities, configuration (including onDisplace), RxJS equivalent, code example, and onDisplace usage example with a custom FetchTransfer (abort pattern).
README — Comparison tables:DisplaceTransfer added to Transfer Comparison Table, Transformation category, operator-equivalent coverage (switchMap→DisplaceTransfer), and Gate/Flow control row.
README — Debounced search example: Updated to use DisplaceTransfer instead of AsyncConvertTransfer directly, demonstrating switch-map semantics.
JSDoc:DisplaceTransfer class and createDisplaceTransfer factory fully documented with mechanics, error handling, configuration, and use cases.
Tests
DisplaceTransfer test suite: 37 tests covering capability flags, basic push & subscribe, displace behavior (cancel previous inner), destroy (dispose inner, clean up subscriptions, idempotent), error handling (factory error with/without onError, previous inner kept active on factory error), real-world scenarios (fetch, WebSocket, readFile, search-as-you-type), async inner transfers (AsyncConvertTransfer, AsyncConditionTransfer), and onDisplace (called with previous inner, not called on first push/destroy, called before destroy, rapid push, custom cleanup, backward-compatible without callback, exception rethrown but inner still destroyed).