-
Notifications
You must be signed in to change notification settings - Fork 431
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
Usage with SwiftUI #849
Comments
Can you describe your issue? ReactiveSwift works fine with SwiftUI, although you will need to use Combine to bridge state changes to an |
I want to map property with @published, any example will help a lot |
How |
You will need to create an For example, something like this: import Combine
import SwiftUI
import ReactiveSwift
class ViewModel: ObservableObject {
public private(set) lazy var objectWillChange = ObservableObjectPublisher()
public let count = MutableProperty(0)
init() {
count.producer.startWithValues { [weak self] _ in
self?.objectWillChange.send()
}
}
}
struct CounterView: View {
@ObservedObject var viewModel: ViewModel
init(viewModel: ViewModel) {
self.viewModel = viewModel
}
var body: some View {
Text("Count is \(viewModel.count.value)")
}
} There is no direct way to map |
No description provided.
The text was updated successfully, but these errors were encountered: