To run the example project, clone the repo, and run pod install
from the Example directory first.
Dependency "RxSwift"
RxSubject is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RxSubject'
##Usage
import RxSubject
In the ViewModel
@RxSubject.Publish
var publishProperty = "publishProperty--000"
@RxSubject.Behavior
var behaviorProperty = "behaviorProperty--000"
@RxSubject.Replay
var replayProperty = "replayProperty--000"
In the ViewController/View
viewModel.publishProperty = "publishProperty--111"
viewModel.publishProperty = "publishProperty--222"
viewModel.$publishProperty.subscribe(onNext: { (property) in
print(property)
}).disposed(by: disposeBag)
viewModel.publishProperty = "publishProperty--333"
viewModel.publishProperty = "publishProperty--444"
viewModel.behaviorProperty = "behaviorProperty--111"
viewModel.behaviorProperty = "behaviorProperty--222"
viewModel.$behaviorProperty.subscribe(onNext: { (property) in
print(property)
}).disposed(by: disposeBag)
viewModel.behaviorProperty = "behaviorProperty--333"
viewModel.behaviorProperty = "behaviorProperty--444"
viewModel.replayProperty = "replayProperty--111"
viewModel.replayProperty = "replayProperty--222"
viewModel.$replayProperty.subscribe(onNext: { (property) in
print(property)
}).disposed(by: disposeBag)
viewModel.replayProperty = "replayProperty--333"
viewModel.replayProperty = "replayProperty--444"
And then you'll see it on the console
publishProperty--333
publishProperty--444
behaviorProperty--222
behaviorProperty--333
behaviorProperty--444
replayProperty--000
replayProperty--111
replayProperty--222
replayProperty--333
replayProperty--444
zsfy, [email protected]
RxSubject is available under the MIT license. See the LICENSE file for more info.