generated from wayfair-incubator/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 4
VSM 2.0 #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
bdunay3
wants to merge
31
commits into
main
Choose a base branch
from
async-vsm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Supports Swift 6+ compiler tools and language mode * Will add in original VSM version once first draft has been vetted
…updates rought drafts.
…gage mode to Swift 5.
…sher is working on the main thread
…tainer is thread-safe and its proeprties atomic
…hing works will with Swift 6 and enforces thread safety
… changes in Instruments
… code moved into Legacy folder.
…nc value of State into the render method
…ad of Combine, as possible
…nit once" semantics like the @StateObject property wrapper
…restrictive and doesn’t by us anything. UIViewController and UIView, which will use RenderedViewState is already Sendable and restricted to MainActor so making the closure that calls the “render” function Sendable doesn’t by us anything and just causes warnings.
…ode. Also removed the refresh method from RenderedViewState because it just doesn’t make sense in UIKit world.
…g on a per view basis
Updated the stateChangeStream function to timeout after a set amount of time. Also made sure that when AsyncStateContainer goes out of scope the active stateChangeStream finishes so it doesn’t hang any code relying on it.
…’t available on GitHub yet)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces AsyncVSM, a Swift Concurrency-based implementation of VSM, while preserving Legacy VSM for backward compatibility. AsyncVSM uses Swift 6 concurrency (
async/await,@MainActor,@Observable) instead of Combine.Key Changes
Architecture
AsyncStateContainerusing Swift ConcurrencySources/LegacyVSM/(Swift 5)Sources/VSM/(Swift 6)Core Implementation
AsyncStateContainer(Sources/VSM/AsyncStateContainer.swift)@Observable(replacesObservableObject)@MainActorfor thread safetyState,StateSequence,AsyncStream,AsyncSequence, and CombinePublisherFailure == Never)ViewState(Sources/VSM/ViewState.swift)@Observable@StateRenderedViewState(Sources/VSM/RenderedViewState.swift)ViewStatefor iOS 26+StateSequence(Sources/VSM/StateSequence.swift)Thread Safety
@MainActorisolation ensures state changes on the main thread@Sendablerequirements for thread-safe closuresMigration Support
observeAsyncmethod preserved (deprecated, redirects toobserve)Publishersupport for gradual migrationDeveloper Experience
Differences: Legacy VSM vs AsyncVSM
ObservableObject,@Published)@Observable,@MainActor)StateContainer<State>AsyncStateContainer<State>observe(_:),observeAsync(_:)observe(_:)with multiple overloadssetStateOnMainThreadchecks@MainActorisolationPublisheronlyStateSequence,AsyncStream,AsyncSequence,PublisherAsyncAlgorithms.debounceFailure == Never)ObservableObjectprotocol@ObservablemacroBenefits
@MainActorisolationTesting
AsyncStateContainerDocumentation
Breaking Changes
None. Legacy VSM remains fully functional. AsyncVSM is additive.
Next Steps
This PR represents a modernization of the VSM library, bringing it in line with Swift 6 and Swift Concurrency while maintaining backward compatibility.
Type of Change
Checklist