Skip to content
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

Add query and cloud code view models for SwiftUI #183

Merged
merged 48 commits into from
Jul 18, 2021
Merged

Conversation

cbaker6
Copy link
Contributor

@cbaker6 cbaker6 commented Jul 3, 2021

Introduces a new type, QueryViewModel which conforms to ObservableObject. The new type serves as a view model property for any Parse Query. Simply call query.viewModel to use the view model with any SwiftUI view. QueryViewModel can be subclassed for customization. In addition, developers can create their own view models for queries by conforming to QueryObservable. LiveQuery Subscription's inherrit from QueryViewModel meaning instances of Subscription provides a single view model that publishes updates from LiveQuery events and traditional find, first, count, and aggregate queries.

Similarly, add CloudViewModel which conforms to ObservableObject. The new type serves as a view model property for any Cloud Code. Simply call cloud.viewModel to use the view model with any SwiftUI view. CloudViewModel can be subclassed for customization. In addition, developers can create their own view models for queries by conforming to CloudObservable

A breaking change is introduced for those use custom subscriptions as ParseSubscription has been renamed to QuerySubscribable

  • Add QueryViewModel
  • Add CloudViewModel
  • Documentation nits
  • Add playgrounds example
  • Move all SwiftUI Playground examples to separate pages
  • Add test cases
  • Add change log entry
  • Prepare for new release

@codecov
Copy link

codecov bot commented Jul 3, 2021

Codecov Report

Merging #183 (db40f10) into main (1f0f614) will increase coverage by 0.13%.
The diff coverage is 91.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #183      +/-   ##
==========================================
+ Coverage   83.14%   83.28%   +0.13%     
==========================================
  Files          74       76       +2     
  Lines        7079     7203     +124     
==========================================
+ Hits         5886     5999     +113     
- Misses       1193     1204      +11     
Impacted Files Coverage Δ
Sources/ParseSwift/Types/ParseBytes.swift 94.44% <ø> (ø)
Sources/ParseSwift/Types/Query.swift 94.95% <ø> (+0.63%) ⬆️
Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift 76.73% <50.00%> (ø)
Sources/ParseSwift/API/URLCache+extensions.swift 53.57% <59.09%> (-16.43%) ⬇️
Sources/ParseSwift/Coding/ParseEncoder.swift 76.29% <100.00%> (+0.98%) ⬆️
Sources/ParseSwift/LiveQuery/Subscription.swift 67.27% <100.00%> (ø)
...es/ParseSwift/LiveQuery/SubscriptionCallback.swift 95.83% <100.00%> (ø)
Sources/ParseSwift/Objects/ParseObject.swift 78.09% <100.00%> (-1.29%) ⬇️
Sources/ParseSwift/Parse.swift 100.00% <100.00%> (ø)
Sources/ParseSwift/Types/CloudViewModel.swift 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f0f614...db40f10. Read the comment docs.

@cbaker6 cbaker6 requested a review from TomWFox July 3, 2021 18:42
@cbaker6
Copy link
Contributor Author

cbaker6 commented Jul 3, 2021

@TomWFox can you review the readme additions and updates?

@cbaker6 cbaker6 closed this Jul 5, 2021
@cbaker6 cbaker6 reopened this Jul 5, 2021
@cbaker6 cbaker6 changed the title Add query view model for SwiftUI Add query and cloud code view models for SwiftUI Jul 11, 2021
@cbaker6 cbaker6 merged commit cb1a8b9 into main Jul 18, 2021
@cbaker6 cbaker6 deleted the queryViewModel branch July 18, 2021 21:09
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.

None yet

1 participant