Swiftpack.co - intuit/swift-hooks as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by intuit.
intuit/swift-hooks 0.1.0
A little module for plugins, in swift.
⭐️ 8
🕓 34 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/intuit/swift-hooks.git", from: "0.1.0")
SwiftHooks Logo

SwiftHooks is a little module for plugins, in Swift


Auto Release CircleCI Cocoapods Cocoapods platforms License GitHub top language GitHub Pages

A Hook represents a "pluggable" point in a software model. They provide a mechanism for "tapping" into such points to get updates, or apply additional functionality to some typed object.

Variety of built in hook types

Type Behavior
Basic Executes the taps with no return value
Waterfall "Reduce" the result through all the taps
Bail Retrieve the result of the first tap that handles the calling value
Loop Execute taps until no taps request the loop be restarted

Visit our site for information about how to use SwiftHooks.

Inspiration

At Intuit, we're big fans of tapable, and plugin architecture. This package is the Swift companion to the Kotlin hooks. These are packages we use to enable extensible software, keeping extensions isolated to those that need them, avoiding bloat in primary projects.

Installation

Swift Package Manager

Install with Swift Package Manager by adding a reference to your Package.swift dependencies:

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/intuit/swift-hooks.git", from: "0.0.1")
    ]
)

CocoaPods

Install with CocoaPods by adding an entry to your Podfile, and then running pod install:

pod 'SwiftHooks'

Structure

Contributing

Feel free to make an issue if you are having trouble or open a pull request if you have an improvement to add!

Make sure to read our code of conduct.

Build

This is a Swift only package, so it can be built easily from the command line:

swift build

Test

Running tests in parallel is preffered as it completes much faster:

swift test --parallel

Lint

This project uses SwiftLint for linting, and follows the default conventions:

swift run swiftlint

Formatting

This project is also set up for SwiftFormat to automatically format code:

swift run swiftformat Sources

GitHub

link
Stars: 8
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.1.0
34 weeks ago

Release Notes

Add support for untapping hooks (#10)

Adds an untap(_:) method to hooks, and has all tap methods return an ID that can be used to untap.


🚀 Enhancement

🐛 Bug Fix

📝 Documentation

Authors: 1

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