Skip to content
/ Epic Public

Swift basic implementation to deal with long tasks. It uses an array-based approach at all times.

License

Notifications You must be signed in to change notification settings

Maquert/Epic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.