The channel and debounce sources moved into Channels/ and Debounce/,
AsyncChunksOfCountAndSignalSequence.swift is now
AsyncChunksOfCountOrSignalSequence.swift, and the Collections guide
lives in the DocC catalog, so these links return 404.
* feat: Add initial naive implementation of flatMapLatest
This introduces a simplified version of the flatMapLatest operator for AsyncSequence, along with a basic unit test. Note that this implementation uses unstructured concurrency and may have race conditions regarding task cancellation.
* refactor: Implement robust flatMapLatest with generation tracking
- Replaces naive implementation with a thread-safe approach using ManagedCriticalState.
- Introduces generation tracking to prevent race conditions where cancelled inner sequences could yield stale values.
- Adds test_interleaving_race_condition to verify correctness under concurrent load.
- Ensures Swift 6 Sendable compliance.
* refactor: Implement high-performance State Machine for flatMapLatest
- Replaces AsyncThrowingStream implementation with a custom AsyncSequence, Storage, and StateMachine.
- Implements explicit state management using Lock for thread safety.
- Handles concurrency between outer and inner sequences robustly.
- Ensures correct cancellation propagation and error handling.
- Verified with test_interleaving_race_condition.
* refactor: Split flatMapLatest into separate files
- Moves AsyncFlatMapLatestSequence.swift to Sources/AsyncAlgorithms/FlatMapLatest/
- Extracts FlatMapLatestStateMachine and FlatMapLatestStorage into their own files.
- Aligns project structure with other complex operators like CombineLatest and Debounce.
* test: Add comprehensive tests for flatMapLatest
- Added test_outer_throwing to verify outer sequence error propagation
- Added test_inner_throwing to verify inner sequence error propagation
- Added test_cancellation to verify proper cancellation handling
- Added test_empty_outer to verify empty outer sequence handling
- Added test_empty_inner to verify empty inner sequence handling
- Fixed test_simple_sequence to be more robust against timing issues
* fix: Make test_outer_throwing stable
- Changed from synchronous map with throwIf to AsyncThrowingStream
- Added delay to ensure proper error propagation timing
- Fixes intermittent test failures
* refactor: Clean up verbose comments in FlatMapLatestStateMachine
- Removed LLM-style thinking comments
- Kept only essential, professional explanations
- No functional changes, all tests pass
* docs: Add comprehensive guide for flatMapLatest
- Added FlatMapLatest.md documentation guide
- Authored by Peter Friese
- Includes introduction, code samples, and use cases
- Covers search-as-you-type, location-based data, and dynamic config examples
- Compares with similar operators in ReactiveX and Combine
* docs: Add evolution proposal for flatMapLatest
- Created SAA-00nn proposal for flatMapLatest operator
- Includes motivation, detailed design, and examples
- Covers implementation strategy with state machine
- Compares with ReactiveX switchMap and Combine switchToLatest
* mapError - transforming failures (#366)
* Implement AsyncMapErrorSequence
* Update the proposal, implementation and tests with formatting, additional details and modifications for being able to push it to a review
* Foratting and preambles
* Update Copyright date for error sequence
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update copyright year for mapError tests
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update availablity and modify the mapError algorithm to be opaque
* Correct pre 6.0 build avail parameters
* Make the formatting of the algorithm accesor a bit more consistent
* Update the 5.8 package builder to define 1.2
* re-run formatter
---------
Co-authored-by: Clive <clive819@gmail.com>
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update the flatMapLatest proposal and implementation to a pitchable state
* Fix race condition in flatMapLatest and add regression test
* chore: Remove test_output.log and add it to .gitignore
---------
Co-authored-by: Philippe Hausler <phausler@apple.com>
Co-authored-by: Clive <clive819@gmail.com>
Co-authored-by: Clive <clive819@users.noreply.github.com>
This is an implementation of share; an algorithm for allowing AsyncSequence types to be iterated by multiple consumers. In addition this cleans up the project to be a starting point for the 1.1 release - it fixes the continuous integration support and configurations but has the cost of only supporting 3 active releases (6.0, 6.1, and 6.2). Previous releases are only going to have legacy support via older released versions.
* Fix the remaining todo on hard cancellation vs soft cancellation
* Update Sources/AsyncAlgorithms/AsyncShareSequence.swift
Co-authored-by: Jamie <2119834+jamieQ@users.noreply.github.com>
* Update the implementation of share to handle sendability requirements, address some edge cases and update to the latest version of the discussion around buffering behaviors as well as adding some documentation and commentary
* Add some first drafts at unit tests for verifying share behaviors
* Cleanup some of the documentation and address feedback for implementation details
* Fix merge damage by restoring the changes from @jamieQ
* Fix up some availability issues w.r.t. sendable metatypes
* Add a preamble to SendableMetatypes.swift
* Add a fallback for next (for pre 6.2 swift's)
* Slight adjustments for older compiler builds and expose the sendable metatypes since those are part of documentation
* Update formatting and gate availability for older compilers
* Speculative fix for pre 6.1 compiler crashes by removing the sending keyword
* Revert "Speculative fix for pre 6.1 compiler crashes by removing the sending keyword"
This reverts commit 875fa81bc6.
* Speculative fix for pre 6.1 compiler crashes by removing the sending keyword, and correct sendable metatype shim availability
* Remove block comment for formatting check
* Take a more conservative approach and roll back to only supporting share on 6.2
* Only test share on 6.2 or newer
* roll back to older sendable metatype constraints
* yet another stab at 5.10 visionOS guards
* Formatting pass
* Disable 5.10 builds and leave those to older releases
* Ignore swift-version files to avoid local swiftly toolchain selection from being required by others
* Renumber the proposals and copy share into a guide
* Add a link from the primary doc interface to share
---------
Co-authored-by: Jamie <2119834+jamieQ@users.noreply.github.com>
# Motivation
We have been discussing this a lot in the other PRs, but in general said that an `AsyncIterator` is the connection between the consuming task and the `AsyncSequence`. If an `AsyncIterator` would be `Sendable` then we don't have that relationship anymore. Therefore, no iterator of an `AsyncIterator` should be `Sendable`.
# Modification
Remove all `Sendable` conformances of the iterators even the conditional ones. We can always add them back later.
* asyncChannel: introduce ChannelToken to model Pending and Awaiting
* asyncChannel: harmonize send and next cancellation
* asyncChannel: add .finished as an emission state
* asyncThrowingChannel: harmonize send and next cancellation
* channel: update documentation for cancellation
* asyncThrowingChannel: make fail set a terminal state
* asyncChannel: align naming on asyncThrowingChannel
* asyncChannel: remove a test base on Task.sleep
* guides: update Channel with non async fail(_:)
* asyncChannel: enforce termination for all when finished
* asyncThrowingChannel: enforce termination for all when finished
* asyncChannel: improve unit tests readability
* asyncChannel: adapt the Guide to the new finish behaviour
* asyncChannel: adapt the Guide to the new finish behaviour