Swiftpack.co -  Maquert/Epic as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Maquert/Epic
Swift basic implementation to deal with long tasks. It uses an array-based approach at all times.
.package(url: "https://github.com/Maquert/Epic.git", from: "0.3")

Epic: Simple operations manager in Swift

Build Status SPM compatible Licence Last commit Platforms Languages Twitter

Epic is a simple operations manager written in Swift.

Features

  • ☑ Throttle
  • ☑ Generator
  • ☑ MessageBus

Throttle

The Throttle regulates how many executions can get through the same bottleneck within a given amount of time.

let throttler = Throttle(interval: 0.2)

...
/// 5 calls to the throttle block
throttler.throttle {
    API.shared.makeRequest(...) // Just 2 came through
}

It prevents overloads on potentially repetitive and intensive calls to a limited resource, and thus these calls will not degrade the performance of the whole system.

For further documentation, check the docs.

Generator

The Generator supplies block operations of a sequence one at a time.

It complies to Swift's IteratorProtocol.

let generator = Generator(operations: [
    Operation("app.open.home_screen", block: { ... }),
    Operation("app.fetch.user_data", block: { ... }),
    Operation("app.populate.home_screen", block: { ... }),
])
var iterator = generator.iterator()
iterator.next(executingBlock: true) 

For further documentation, check the docs.

Message Bus

The MessageBus is a single entry for all your broadcast messages within your application.

It provides support for brokers and topics through protocols, so you can also inter-operate with your own.

By using a MessageBus all of your messages have the same structure (type and payload). Only the subscribed recipients are able to retrieve the right information for their purposes.

static let messageBus = MessageBus()

messageBus.send(messages: [
    Message(types: ["analytics"], payload: [:...]})
    Message(types: ["user_event", "debug"], payload: [:...])
])

For further documentation, check the docs (Documentation in Progress).

Extensions

Currently, only one extension over Sequence is included in Epic.

For further documentation, check the docs.

Installation

Swift Package Manager

The Swift Package Manager is Apple's official tool for automating the distribution of Swift code.

Add Epic to your Project’s ‘Swift Packages’ section or add Epic as a dependency to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/Maquert/Epic.git", .upToNextMajor(from: "0.2.2"))
]

Use

import Epic

Credits

Epic is maintained by Miguel Hernández Jaso.

Header backdrop photo is a creation by Daniela Rogoza.

GitHub

link
Stars: 3
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

Make throttle blocks non optional
2 weeks ago

Summary

Since 0.3, the Throttle won't deal with nil operations when calling to the throttle method.

Breaking changes

This might break some calls to the throttle function, but those are minor changes clients probably were not dealing with anyway.

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