Skip to content

vetrek/SwiftObservable

Repository files navigation

SwiftObservable

Easyily Observe value changes in Swift.

Installation

Cocoapod

pod 'SwiftObservable'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

In Xcode 11+ select File > Packages > Add Package Dependency
Enter this project's URL: https://github.com/Valerio69/SwiftObservable

Usage

import SwiftObservable

@Observed var name: String = "Jhon"

// Add a new observer (or multiple observers)
$name.observe(on: self) { (oldValue, newValue) in
    print(oldValue) 
    print(newValue) 
}

// Update the value
name = "Patric"

// Remove an observer
$name.remove(observer: self)

// Remove all observers
$name.removeAllObservers()

About

Swift Properties Observer

Resources

License

Stars

Watchers

Forks

Packages

No packages published