Swiftpack.co -  sergejs/StateMachine as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Swift implamentation of Finite State Machine using Combine & Generics
.package(url: "https://github.com/sergejs/StateMachine.git", from: "1.2.2")


Package containing easy implamentation of Finite State Machine using Combine

To start using, all you need is to defeine enums with States and Events, and define Transitions.


[ ] Improved logging control

Example usage

enum TestEvents: EventProtocol {
  case event1, event2

enum TestStates: StateProtocol {
  case initial, step1, step2, step1Alt, finish

let stateMachine = StateMachine<TestEvents, TestStates>(with: .initial)
let transition = StateMachineTransition<TestEvents, TestStates>(event: .event1, from: .initial, to: .finish)
try? stateMachine.append(transition: transition)
XCTAssertEqual(stateMachine.state.value, .initial)

XCTAssertEqual(stateMachine.state.value, .finish)

Check tests for more usage exmples


Stars: 3
Last commit: 6 days 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.


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