Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.
/ subscription Public archive

Type-safe subscription to NotificationCenter with self unsubscription

License

Notifications You must be signed in to change notification settings

clmntcrl/subscription

Repository files navigation

Subscription

Type-safe subscription to NotificationCenter with self unsubscription.

Usage

let valueDidChange = Subscription<String>(name: "valueDidChangeNotification")

var value: String = "ok" {
    didSet { valueDidChange.next(value) }
}

let subscriptionToken = valueDidChange.subscribe { print($0) }
value += "!" // print: "ok!"

For more details, feel free to take a look at Subscription.playground.

Installation

Add the following dependency to your Cartfile:

github "clmntcrl/subscription" ~> 0.1

Add the following pod to your Podfile:

pod 'Subscription', '~> 0.1'

Add the package as dependency in your Package.swift:

dependencies: [
    .package(url: "https://github.com/clmntcrl/swidux-subscription.git", from: "0.1.1"),
]

License

Subscription is released under the MIT license. See LICENSE for details.

About

Type-safe subscription to NotificationCenter with self unsubscription

Resources

License

Stars

Watchers

Forks

Packages

No packages published