nixzhu / Redstone
Licence: mit
Redstone has a State Machine
Stars: ✭ 36
Programming Languages
swift
15916 projects
Labels
Projects that are alternatives of or similar to Redstone
Automatonymous
A state machine library for .Net - 100% code - No doodleware
Stars: ✭ 516 (+1333.33%)
Mutual labels: state-machine
Stately.js
Stately.js is a JavaScript based finite-state machine (FSM) engine for Node.js and the browser.
Stars: ✭ 785 (+2080.56%)
Mutual labels: state-machine
Workflow
A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Stars: ✭ 860 (+2288.89%)
Mutual labels: state-machine
Copycat
A novel implementation of the Raft consensus algorithm
Stars: ✭ 551 (+1430.56%)
Mutual labels: state-machine
Rxautomaton
🤖 RxSwift + State Machine, inspired by Redux and Elm.
Stars: ✭ 711 (+1875%)
Mutual labels: state-machine
Aasm
AASM - State machines for Ruby classes (plain Ruby, ActiveRecord, Mongoid, NoBrainer, Dynamoid)
Stars: ✭ 4,474 (+12327.78%)
Mutual labels: state-machine
Mineflayer Statemachine
A state machine plugin for Mineflayer to aid in designing more complex behavior trees.
Stars: ✭ 32 (-11.11%)
Mutual labels: state-machine
Finite machine
A minimal finite state machine with a straightforward syntax.
Stars: ✭ 772 (+2044.44%)
Mutual labels: state-machine
Cycle State Machine Demo
Non-trivial, real use case demo of a hierarchical state machine library with cyclejs
Stars: ✭ 25 (-30.56%)
Mutual labels: state-machine
State machines
Adds support for creating state machines for attributes on any Ruby class
Stars: ✭ 571 (+1486.11%)
Mutual labels: state-machine
Little State Machine
📠 React custom hook for persist state management
Stars: ✭ 654 (+1716.67%)
Mutual labels: state-machine
Laravel Stager
Laravel Stager State Machine, Its purpose is to add state machine functionality to models
Stars: ✭ 16 (-55.56%)
Mutual labels: state-machine
State Machine Cat
write beautiful state charts 🙀
Stars: ✭ 509 (+1313.89%)
Mutual labels: state-machine
Behaviortree.cpp
Behavior Trees Library in C++. Batteries included.
Stars: ✭ 793 (+2102.78%)
Mutual labels: state-machine
Perl Workflow
Simple, flexible system to implement workflows
Stars: ✭ 10 (-72.22%)
Mutual labels: state-machine
Redstone
Redstone has a State Machine.
Requirements
Swift 4, iOS 8
(Swift 3, use version 0.3.0)
Example
If your room has lights, you can turn it on or turn it off. If you cut the wire, it will borken.
We can define states and transitions to descripe the state machine:
import Redstone
class Lights {
enum State: Int {
case off
case on
case broken
}
enum Transition: Int {
case turn
case cut
}
lazy var stateMachine: StateMachine<State, Transition> = {
let stateMachine = StateMachine<State, Transition>()
stateMachine.add(state: .off) {
print("Lights off")
}
stateMachine.add(state: .on) {
print("Lights on")
}
stateMachine.add(state: .broken) {
print("Lights broken")
}
stateMachine.add(transition: .turn, fromState: .off, toState: .on)
stateMachine.add(transition: .turn, fromState: .on, toState: .off)
stateMachine.add(transition: .cut, fromStates: [.on, .off], toState: .broken)
return stateMachine
}()
}
We create a lights, set it's initial state to off.
let lights = Lights()
lights.stateMachine.initialState = .off
Now you can turn the lights from off to on, or from on to off:
lights.stateMachine.fire(transition: .turn)
Or cut the wire:
lights.stateMachine.fire(transition: .cut)
It will can not been turn on again.
Run the demo to feel it if you like.
Installation
Carthage
github "nixzhu/Redstone"
CocoaPods
pod 'Redstone'
Contact
NIX @nixzhu
License
Redstone is available under the MIT license. See the LICENSE file for more info.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].