Skip to content

Simple and lightweight Observable framework in Swift

Notifications You must be signed in to change notification settings

PvParisi/Observable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Observable

Simple and lightweight Observable framework in Swift

Usage

Just add the Observable.swift and ObservableOptions.swift to your project.

Create your observable property:

var batteryPercentage: Observable<Int> = Observable(0)

Start observing and react to its changes by adding an observer:

batteryPercentage.addObserver(observerObject, options: [.initial, .new]) { [weak self] (percentage, _) in
            print("Your current battery percentage is: \(percentage)%")
        }

If you want, you can stop observing anytime simply by removing the observer:

batteryPercentage.removeObserver(observerObject)

There's no need to explicitly remove it if you don't want to, it will be automatically removed at deallocation.

Have a look at the sample app for more information.

About

Simple and lightweight Observable framework in Swift

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages