Swiftpack.co - Package - nfam/variable.swift

Variable.swift

swift platform build codecov license

Represents a value that changes over time.

Install

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/nfam/variable.swift.git", majorVersion: 0, minor: 1)
    ]
)

Usage

let variable = Variable<String>(value: "Initial value")

// `variable` does have `subscribe` method,
// however wrapping it with `Subscribable` will stop subscribers from setting the variable value.
let subscribable = Variable<String>.Subscribable(variable)

variable.next(value: "Not printed!")
variable.next(value: "Not printed!")
variable.next(value: "Printed!")

subscribable.subscribe { value in
    print(value)
}

subject.onNext("Printed!")

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0