-
Notifications
You must be signed in to change notification settings - Fork 4
Adaptation for Swift 6 #2
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
Open
maykonmeneghel
wants to merge
9
commits into
main
Choose a base branch
from
feature/swift-6
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.
Open
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
@dotswift please take note
…On Fri, Feb 21, 2025 at 10:37 Maykon Meneghel ***@***.***> wrote:
Description: 1️⃣ Refactored ContentViewModel to use @observableobject
<https://github.com/observableobject> correctly
ContentViewModel now correctly conforms to the ObservableObject protocol,
ensuring that the SwiftUI UI responds to state changes.
2️⃣ Updated ViewModel lifecycle in ContentView
ContentView now correctly manages the ContentViewModel instance using
@StateObject <https://github.com/StateObject>, ensuring that the
ViewModel is preserved throughout the View's lifecycle.
Created an initializer in ContentView that accepts a ContentViewModel,
allowing greater flexibility in dependency injection.
3️⃣ Use of async / await to improve asynchronous execution
The fetchContents() in ContentViewModel is now fully asynchronous (async
throws), avoiding blocking in the UI.
ContentView now uses .task { try await viewModel.fetchContents() },
ensuring that data fetching occurs correctly without blocking screen
rendering.
4️⃣ Using actors and isolated let to improve concurrency and security
ContentRepositoryImpl has been transformed into an actor, ensuring that
concurrent accesses are safe.
Using isolated let inside the actor to optimize performance, ensuring that
datasource is a safe and immutable value.
------------------------------
You can view, comment on, or merge this pull request online at:
#2
Commit Summary
- 975ad6e
<975ad6e>
fix: put async / await
- bba4533
<bba4533>
fix: change to actor in the repository impl
- 9c55f1a
<9c55f1a>
fix: add main actor
- a7a8387
<a7a8387>
fix: content view as observable object
- 8333610
<8333610>
fix: change the dependency injection
- 2e3f877
<2e3f877>
fix: get the contents from the view model
- 5fe6272
<5fe6272>
fix: add aync / await in the use ase
- f4d26fb
<f4d26fb>
fix: update the ios target
File Changes
(9 files <https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files>)
- *M* Content Generator.xcodeproj/project.pbxproj
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-b878a363964a2abaaeac4a8990a27860a309963f2481c0ef0a5bd2dfea3e161a>
(4)
- *M* Content
Generator/Features/CreateContent/Domain/Repositories/ContentRepository.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-8c70ff1398440589771a0b119e3ba9dd6c067564b2143bccab486041b3a38621>
(2)
- *M* Content
Generator/Features/CreateContent/Domain/UseCases/FetchContentsUseCase.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-303f91dbecf88c11e9133d781375e0c3e8c113a0336102df3801836fad90d0b8>
(6)
- *M* Content
Generator/Features/CreateContent/External/Datasource/Remote/ContentRemoteDatasource.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-36b2f3920a61c5ef2a284e52e0104cd9d15ce1e8fb589474ec0dec50468fcea8>
(15)
- *M* Content
Generator/Features/CreateContent/Infra/Datasource/ContentDatasource.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-c19963a2d532f43ec2444060877cc4cc8654fb23b346fa21c5cf459ade3b8766>
(2)
- *M* Content
Generator/Features/CreateContent/Infra/Repositories/ContentRepositoryImpl.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-e1e8bd40d07c6b1cea5436f260d417a395ab5a69a2b3a8d7b911943cf8a3e0de>
(12)
- *M* Content
Generator/Features/CreateContent/Presentation/ContentViewModel.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-65e1045dcc931a6a3d06c78c4825b6e04113e34e2f30a0fb6eaff87c7d7ad54e>
(16)
- *M* Content
Generator/Features/CreateContent/Presentation/UI/ContentView.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-3f02609b329cfa1d3e231ae9467a7f2657bb26a29d679f76c0aef87581c92c62>
(20)
- *M* Content
Generator/Injectors/FeatureInjectors/ContentInjector.swift
<https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2/files#diff-8f83ac415b8f3791b1ed462d876af99ac6ef50828e330d15114b87647a24e09d>
(1)
Patch Links:
- https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2.patch
- https://github.com/maykonmeneghel/Clean-SwiftUI/pull/2.diff
—
Reply to this email directly, view it on GitHub
<#2>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOJBPYHTU5BWJYTHJKEC3AD2QZRL7AVCNFSM6AAAAABXR7CNICVHI2DSMVQWIX3LMV43ASLTON2WKOZSHA3DONJRGQ2DSMI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
cc63011
to
6063273
Compare
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.
Article:
Description:
1️⃣ Refactored ContentViewModel to use @observableobject correctly
ContentViewModel now correctly conforms to the
ObservableObject
protocol, ensuring that the SwiftUI UI responds to state changes.2️⃣ Updated ViewModel lifecycle in ContentView
ContentView now correctly manages the ContentViewModel instance using @StateObject, ensuring that the ViewModel is preserved throughout the View's lifecycle.
Created an initializer in ContentView that accepts a ContentViewModel, allowing greater flexibility in dependency injection.
3️⃣ Use of async / await to improve asynchronous execution
The fetchContents() in ContentViewModel is now fully asynchronous (async throws), avoiding blocking in the UI.
ContentView now uses .task { try await viewModel.fetchContents() }, ensuring that data fetching occurs correctly without blocking screen rendering.
4️⃣ Using actors and isolated let to improve concurrency and security
ContentRepositoryImpl has been transformed into an actor, ensuring that concurrent accesses are safe.
Using isolated let inside the actor to optimize performance, ensuring that datasource is a safe and immutable value.