Swiftpack.co - BlueEventHorizon/BwPublisher as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by BlueEventHorizon.
BlueEventHorizon/BwPublisher 2.0.6
PPublisher is the light weight publish/subscribe library
⭐️ 2
🕓 1 year ago
iOS
.package(url: "https://github.com/BlueEventHorizon/BwPublisher.git", from: "2.0.6")

BwPublisher

Release License Twitter

BwPublisher is the light weight publish/subscribe library

This library can be used for the purpose of operating loosely coupled between software layers like RxSwift and Combine Framework. It's very lightweight and consumes little memory, as only the minimum amount of observing functionality is implemented. It is suitable for use in apps with limited memory, such as App Clips introduced from iOS14.

Usage

it is very easy to use BwPublisher

Publisher


class Hoge {
    var publisher = Publisher<String>()
    
    func action() {
        publisher.send("Hoge Updated")
    }
}

Subscriber


class Fuga {

    let hoge = Hoge()
    var bag = SubscriptionBag()
    
    ... invoke configure() at somwhere ...
    
    func configure() {
        hoge.publisher
            .sink(self) { [weak self] message in
                print(message)
            }
            .unsubscribed(by: bag)
    }
}

GitHub

link
Stars: 2
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

BwPublisher 2.0.6
1 year ago
  • change func subscribe -> sink
  • fix test
  • update README.md

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