RxSwift – Observe IBOutlet change

//  ViewController.swift
//  RxSwift-example1
//  Created by sandesh sardar on 23/05/19.
//  Copyright © 2019 sandesh sardar. All rights reserved.

import UIKit
import RxSwift
import RxCocoa

class ViewController: UIViewController {
    @IBOutlet weak var slider: UISlider!
    @IBOutlet weak var sliderValue: UILabel!

    let disposeBag = DisposeBag() // for memory management
    override func viewDidLoad() {
        self.slider.rx.value // made slider as observable
            //subscribe to above observable
            .subscribe(onNext: { slidervalue in
               self.sliderValue.text = "\(slidervalue)"
            }).disposed(by: disposeBag)

git clone https://sandeshsss@bitbucket.org/sandeshsss/rxswift-example1.git

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s