Swiftpack.co - vetrek/SwiftObservable as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by vetrek.
vetrek/SwiftObservable 0.0.7
Swift Properties Observer
⭐️ 3
🕓 2 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/vetrek/SwiftObservable.git", from: "0.0.7")

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()

GitHub

link
Stars: 3
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics