AGStateMachineBuilder - a library for easy creation of state machines using advanced concepts of kotlin

Overview

AGStateMachineBuilder

Introduction

This is a library for easy creation of state machines using advanced concepts of kotlin. As of 2/15/2022, this library only works in kotlin, but will be expanded to work in Java later (whenever I get bored enough to rewrite an entire code structure in java :/ ).

Usage

For creating a state machine, you can use the AGStateMachineBuilder.kt class, such as follows:

val stateMachine = AGStateMachineBuilder {
    state("first") {
        enter {
            //code that runs one time when entering the state
        }
        
        loop {
            //code that runs every time the state is active
            true //some condition here that returne a boolean, (ALWAYS PUT AT AND OF SEGMENT)
        }
        
        exit {
            //code that runs one time when exiting the state
            nextState("second")
        }
    }
    
    state("second") {
        enter {
            //code that runs one time when entering the state
        }
        
        loop {
            //code that runs every time the state is active
            true //some condition here that returne a boolean, (ALWAYS PUT AT AND OF SEGMENT)
        }
        
        exit {
            //code that runs one time when exiting the state
            //since this is the last state, we dont need a next stage call here
        }
    }
}

So now we defined a state machine, and we can use it to create a state machine object like so:

while (!stateMachine.allStatesCompleted){
    stateMachine.run()
}
You might also like...
Event State Processor Generator plugin is compatible with IntelliJ and Android Studio.
Event State Processor Generator plugin is compatible with IntelliJ and Android Studio.

Event State Processor Generator plugin is compatible with IntelliJ and Android Studio. It provides source code generation for the EventStateProcessor Library to increase code productivity in Flutter apps development.

🚀🧨📝 Series of Tutorials to learn about Jetpack Compose with subjects Material Widgets, Layout, SubcomposeLayout, custom layouts, State, custom rememberable, recomposition, LaunchedEffect, side-effects, Gesture, Animation,  Navigation, Canvas, UIs like whatsapp and others. Amazing and easy to use Accordion Library for Android built with kotlin
Amazing and easy to use Accordion Library for Android built with kotlin

AccoLib An easy-to-use, amazing Accordion Library for Android built with kotlin. It reduces the amount of code needed to make Accordions in android, w

Tools for Kotlin/Kscript to easy write shell command line in kotlin code

Kscript Tools Easy way to run shell command line in kotlin and other tools Usage Used in kscript: @file:DependsOn("com.sealwu:kscript-tools:1.0.2") Us

A basic library that enables easy composition of gesture sequence recognition on a view

GestureSequence A basic library that enables easy composition of gesture sequence recognition on a view. Basic API looks like: // Perform action() whe

Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

Katoot - An easy-to-use (blocking) Kotlin wrapper for Kahoot's REST api

katoot An easy-to-use (blocking) Kotlin wrapper for Kahoot's REST api. Usage Qui

Learn Kotlin, easy bites at a time
Learn Kotlin, easy bites at a time

Welcome! I hope you're having an amazing day! 🚀 This repository is a reference of how I think one should approach learning kotlin step-by-step. Insid

This is a sample app to demonstrate the power of using EventSourced models and the ease with which these can be modelled using Kotlin.
This is a sample app to demonstrate the power of using EventSourced models and the ease with which these can be modelled using Kotlin.

Lego 4 Rent This is a sample app to demonstrate the power of using EventSourced models and the ease with which these can be modelled using Kotlin. To

Owner
Sanjay Mohan
AlphaGo 16439 Captain & Programmer
Sanjay Mohan
Project build to understand the concepts of Git and GitHub

Project build to understand the concepts of Git and GitHub. Summarizing the concepts learnt. Created a project in Android Studio Before installing And

Rifah A Khan 0 Oct 6, 2021
Sandbox project for modeling concepts

Sandbox project for modeling concepts. UX purchased: https://ui8.net/royalz-store/products/deleted-611ca51f04f024004251da7b Reference to Figma: https:

Philip 1 Dec 28, 2021
A sandbox where I will experiment with new techniques, concepts, and technologies.

A sandbox where I will experiment with new techniques, concepts, and technologies. Here you will find some DDD, CQRS, Clean Architecture, Event-Driven Architecture, Serverless, Microservices, RabbitMQ, gRPC, SOLID, Design Patterns, and more.

Jefferson Didi Silva 6 Nov 15, 2022
Template to accelerate the creation of new apps using Spring Boot 3, MongoDB & GraphQL.

Template to accelerate the creation of new apps using Spring Boot 3, MongoDB & GraphQL.

André Ramon 1 Feb 13, 2022
🐹 Kotlin microservice to aid slash command creation for Nino.

slash-commands ?? .Kotlin microservice to aid slash command creation for Nino. More of this README will be fixed up once the first release is here. Li

Nino 5 Oct 1, 2021
An advanced environment variable parsing library for Kotlin.

EnvSchema An advanced environment variable parsing library for Kotlin. Features Supported features Parsing of objects Parsing of nested objects Custom

Cody 1 Apr 12, 2022
Code for the Advanced Android Kotlin Testing Codelab 5.1-5.3

TO-DO Notes - Code for 5.1-5.3 Testing Codelab Code for the Advanced Android Kotlin Testing Codelab 5.1-5.3 Introduction TO-DO Notes is an app where y

Jorge M 1 Jun 7, 2022
MI Pad 2 tablet advanced boot options

LatteGO MI Pad 2 tablet advanced boot options Features Hidden target device checker Simple GUI Reboot options Shutdown Recovery Fastboot DNX Reboot Sl

null 4 Oct 26, 2022
🧮 Provides simple and advanced mathematical functions in a beautifully designed UI.

Calculator ?? Android App ?? Download the App ?? What is this App ✍️ This will basically provide simple and advanced mathematical functions in a beaut

Ayush Agnihotri 9 Jan 31, 2023
Resultat is kotlin.Result with a loading state

What is Résultat? Résultat is a fork of Kotlin Result with a loading state. Why? Because sometimes you start a project based on Kotlin Result and you

null 41 Dec 10, 2022