Skip to content

Conversation

@JonMercer
Copy link
Collaborator

  • adds a combine wrapper to SAPlayer.Update
  • use the wrapper in a SwiftUI friendly way

image

import SwiftUI

struct ContentView: View {
@StateObject var saUpdates = SAPlayer.SAPlayerCombine.shared
Copy link
Collaborator Author

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")!
Copy link
Collaborator Author

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?
Copy link
Collaborator Author

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.

@JonMercer JonMercer changed the title Add a super basic implementation of Combine and SwiftUI. Add a super basic implementation of Combine and SwiftUI sample project Apr 22, 2021
@JonMercer
Copy link
Collaborator Author

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.

@jiangdi0924
Copy link
Contributor

  • adds a combine wrapper to SAPlayer.Update
  • use the wrapper in a SwiftUI friendly way

image

it's great !

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.

3 participants