-
Notifications
You must be signed in to change notification settings - Fork 111
Add a super basic implementation of Combine and SwiftUI sample project #100
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
base: master
Are you sure you want to change the base?
Conversation
| import SwiftUI | ||
|
|
||
| struct ContentView: View { | ||
| @StateObject var saUpdates = SAPlayer.SAPlayerCombine.shared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going to use saUpdates in multiple views, consider moving this to your App file and inject it into each view. For each view save it as @ObservedObject instead of @StateObject
| .padding() | ||
| Button(action: { | ||
| guard let status = saUpdates.update.playingStatus else { | ||
| let url = URL(string: "https://chtbl.com/track/18338/traffic.libsyn.com/secure/acquired/Acquired_-_Rec_Room_-_Final.mp3")! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this stuff out of the view layer.
|
|
||
|
|
||
| struct CombineUpdate { | ||
| var url: URL? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this won't be a nil because we should be using a PassthroughSubject. However, most new users are used to @Published so I went with that.
If you're going to heavily use this player with SwiftUI consider making a PR using PassthroughSubject, or at least let me know and I'll implement that.
|
T, could you try running the project on your end? I didn't actually use the podfile, but instead linked (symlink I guess?) to the source files directly. My guess was that some users might just want an example to use in their project. I ran the UIKit project and I had a bunch of podfiles and plist stuff leftover that I didn't think I should commit. |

SAPlayer.Update