See below code.
class ViewController4: UIViewController {
var disposeBag = DisposeBag()
let v = Variable(0)
override func viewDidLoad() {
super.viewDidLoad()
v.asObservable()
.subscribe(onNext: { print($0) })
.disposed(by: disposeBag)
v.value = 1
}
}
When it runs, it will print
0
1
However, I don't want it to run on 0
, or saying 0
is just the value used to initiate v
. Can I do that? Or I have to postpone the code at the time point when I use it?