Swiftpack.co -  crane-hiromu/CombineStorable as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Handy Combine extensions on NSObject, including Set.
.package(url: "https://github.com/crane-hiromu/CombineStorable.git", from: "1.0.0")




If you're using Combine, you've probably encountered the following code more than a few times.

class Object: NSObject {
    var cancellables = Set<AnyCancellable>()


Instead of adding a new property to every object, use this library to add it for you, to any subclass of NSObject.


final class Object: NSObject, Storable { // import Storable

    // You don't have to write this.
    // private var cancellables = Set<AnyCancellable>()

    func exec() {
            .sink(receiveCompletion: { _ in
                // do something
            }, receiveValue: { _ in 
                // do something
            .store(in: &self.cancellables) // read Set<AnyCancellable> in yourself.

You can read Set<AnyCancellable> without member variable. It'll work just like a property: when the instance is deinit'd, the Set<AnyCancellable> gets disposed. It's also a readwrite property, so you can use your own, too.

Furthermore, .store(in: &self.cancellables) can be omitted.


final class Object: NSObject, Storable {

    func exec() {
            .sink(self, receiveCompletion: { _ in // input self
                // do something
            }, receiveValue: { _ in 
                // do something

For a detailed explanation, please read here.



Add the following line to your Podfile:

pod 'CombineStorable', :git => 'git@github.com:crane-hiromu/CombineStorable.git', :branch => 'main'


Add the following to your Cartfile:

github "crane-hiromu/CombineStorable"

Swift Package Manager

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/crane-hiromu/CombineStorable.git", from: "1.0.0")


MIT, of course ;-) See the LICENSE file.


Stars: 10
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

First Release
2 weeks ago

Changes 🆕

  • Release
  • Support for Cocoapods
  • Support for Carthage
  • Support for SPM

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