Swiftpack.co - tomwilsn/UIAlertControllerCombine as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by tomwilsn.
tomwilsn/UIAlertControllerCombine 1.0.0
Present UIAlertController using Combine futures
⭐️ 2
🕓 4 years ago
iOS
.package(url: "https://github.com/tomwilsn/UIAlertControllerCombine.git", from: "1.0.0")

UIAlertControllerCombine

An extension for UIAlertController that will output the result as a Future of any type.

Example

enum ConfimationEnum: CaseIterable {
    case Cancel, Confirm
}

var subscriptions = Set<AnyCancellable>()

UIAlertController(title: "Something Alarming",
                  message: "Are you sure you want to do this?",
                  preferredStyle: .alert)
    .show(presenter: self, actions: [
        UIAlertControllerCombineAction(title: "Cancel", style: .cancel, event: ConfirmationEnum.Cancel),
        UIAlertControllerCombineAction(title: "Delete", style: .destructive, event: ConfirmationEnum.Confirm),
        ]
).sink { [weak self] result in
    switch result {
    case .Cancel:
        break
    case .Confirm:
        self?.doConfirmAction()
   }
}
.store(in: &subscriptions)

GitHub

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

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