Kotlin coroutine capable Finite-State Machine (multiplatform)

Overview

Comachine

Features

  • Kotlin corutines. Event handlers can launch coroutines for collecting external events of performing side effects.
  • Structured concurrency. Each states is launched in its own coroutine scope, called state scope. Coroutines running in a state scope will be properly cancelled on each state transition.
  • Suspendable event handlers. Four built-in suspendable event handler types can simplify handling of events.
  • Decomposition by feature. State machine can delegate declaration and handling of events to independent features.
  • State extras. Fearures can store objects in the current state even if they are not a part of the state type.

Examples

  1. Simple state machine
  2. Delegation and code decomposition

Binaries

// in project build file
allprojects {
    repositories {
        maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
}

// in module build file
dependencies {
    implementation 'de.halfbit:comachine-jvm:1.0-SNAPSHOT'
}
You might also like...
Android application showcasing the MVVM architecture, Clean code using Kotlin, Coroutine, Flow and databinding.
Android application showcasing the MVVM architecture, Clean code using Kotlin, Coroutine, Flow and databinding.

Code4Lyst Android application showcasing the MVVM architecture, Clean code using Kotlin, Coroutine, Flow and databinding. App Architecture MVVM CleanC

A Gallery app developed using kotlin and MVVM architecture with Coroutine

A Gallery app developed using kotlin and MVVM architecture Loading image from un

Android - kotlin Coroutine with MVVM and Paging 3
Android - kotlin Coroutine with MVVM and Paging 3

Android - kotlin Coroutine with MVVM and Paging 3 To Loarn more about paging 3 To Loarn more about LoadStateAdapter API Reference Get all items Api So

Coroutine for Bukkit

Heartbeat Coroutines 두근두근 ❤️ 코루틴 Coroutine for Paper Features Bukkit의 mainHeartBeat(GameLoop)에서 dispatch되는 Coroutine JavaPlugin 생명주기의 CoroutineScope 유

Android Clean Architechture with MVVM, LiveData, Coroutine, Dagger Hilt, Room, DataStore
Android Clean Architechture with MVVM, LiveData, Coroutine, Dagger Hilt, Room, DataStore

MovKu An application that displays a list of popular movies and detail Concepts Tech Stack Kotlin -A modern programming language that makes developers

Simple State Machines in Kotlin (KSSM)
Simple State Machines in Kotlin (KSSM)

Simple State Machines in Kotlin (KSSM) What is this? KSSM (reordered: Kotlin - Simple State Machines) provides an easy and simple DSL (Domain Specific

Stresscraft - State-of-art Minecraft stressing software written in Kotlin

StressCraft (W.I.P) State-of-art Minecraft stressing software written in Kotlin.

ScopedState - Android Scoped State With Kotlin

Android Scoped State There is no need for complicated code - just define scopes

This repository contains the article describing my attempt to implement a simple state reducer based on Kotlin Flow and an example app that uses it.
This repository contains the article describing my attempt to implement a simple state reducer based on Kotlin Flow and an example app that uses it.

This repository contains the article describing my attempt to implement a simple state reducer based on Kotlin Flow and an example app that uses it.

Comments
  • Release 1.0

    Release 1.0

    API refinement

    • [x] Make onEnter non suspending
    • [x] Add non suspending on<Event>
    • [x] Add getExtra and setExtra methods
    • [x] Add support for multiple handlers for the same event (to be used in delegates) & main handlers
    • [x] Rename launch into launchInState to distinguish it from coroutine's launch

    Tests

    • [x] Add tests for updateState {}
    • [x] Add tests for transitionTo {}
    • [x] Add tests for onEnter {}
    • [x] Add tests for onExit {}
    • [x] Add tests for onSequential<Event> {}
    • [x] Add tests for onConcurrent<Event> {}
    • [x] Add tests for onLatest<Event> {}
    • [x] Add tests for onSingle<Event> {}

    Runtime validation

    • [x] Prevent from adding multiple handlers of the same event type (with tests)
    • [ ] Prevent already started comachine from starting again (with tests)

    Documentation

    • [ ] Add DSL documentation
    • [ ] Create quick reference - a single page documentation describing all features

    Configuration

    • [x] Configure release upload to maven
    • [ ] Configure CI build & tests
    • [ ] Update README.md

    Composition

    • [x] Add DSL and implementation for machine composition
    • [x] Add documentation
    • [x] Add tests
    opened by sergejsha 0
Owner
Sergej Shafarenka
Android Expert and Software Architect
Sergej Shafarenka
🔴 A non-deterministic finite-state machine for Android & JVM that won't let you down

HAL is a non-deterministic finite-state machine for Android & JVM built with Coroutines StateFlow and LiveData. Why non-deterministic? Because in a no

Adriel Café 73 Nov 28, 2022
This Project for how to use MVVM , state flow, Retrofit, dagger hit, coroutine , use cases with Clean architecture.

Clean-architecture This Project for how to use MVVM , state flow, Retrofit, dagger hit, coroutine , use cases with Clean architecture. Why i should us

Kareem Aboelatta 10 Dec 13, 2022
Kotlin Multiplatform Coffee Machine

Expressus KMM sample project acting as a playground to illustrate what's discussed in these articles: Details Shared Model-View-Intent architecture Fi

Guilherme Delgado 56 Dec 22, 2022
🧸 A multiplatform coroutine-based wrapper for popular platform-specific Redis client libraries

?? rekt ⚠️ WARNING! This project is experimental and may be missing essential features. Please let us know if you found any issues or have any suggest

Hexalite Network 3 Aug 31, 2022
🧸 A multiplatform coroutine-based wrapper for popular platform-specific Redis client libraries

?? rekt ⚠️ WARNING! This project is experimental and may be missing essential features. Please let us know if you found any issues or have any suggest

Southdust Team 3 Aug 31, 2022
A Java Virtual Machine written in Kotlin

jvm.kotlin A Java Virtual Machine written in Kotlin. Introduction jvm.kotlin is a toy JVM programmed in Kotlin. The main purpose of this project is le

Elements 14 Aug 13, 2022
ClickMachine Fabric - Click Machine for minecraft

Minecraft mod for Fabric Adds one block to the game: Auto Clicker. This autoclic

null 0 Jan 10, 2022
Download tool based on kotlin and coroutine.

DownloadX A multi-threaded download tool written with Coroutine and Kotlin Read this in other languages: 中文, English, Changelog Prepare Add jitpack re

Season 138 Dec 22, 2022
Kotlin Coroutine için örnek proje

Kotlin Coroutines Kotlin Coroutines: Senkron kod yazarak asenkron uygulamalar geliştirmeye yarayan bir eklentidir. Network istekleri cevap gelene kada

Murat YÜKSEKTEPE 3 Dec 7, 2022
Skeleton project for show the architecture of Android project using MVVM, Clean Architecture and Kotlin coroutine Flow

ClearScoreDemo Skeleton project for showing the architecture of Android project using MVVM, Clean architecture and Kotlin coroutine Flow App Architect

Plabon Modak 1 Mar 6, 2022