Skip to content

Simple state-management library based around state manipulators holding objects to manage states.

License

Notifications You must be signed in to change notification settings

ItsThosea/flowpoolapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlowPoolAPI

...is a simple-yet-powerful state management system based around the HandlerPool.

Why?

Time after time I see the broken state-machine approach games and libraries use like OpenGL.
While this initially works, once more than one source affects one state, the state will be reverted earlier than expected.
Take something like this:

Runnable someCallback = () -> {
	entity.setSomeProperty(true);
	entity.doCalculation();
	entity.setSomeProperty(false); 
};

entity.setSomeProperty(true);
entity.doCalculation(); // I expect `someProperty` to be true.
someCallback.run();
entity.doOtherCalculation(); // Oops! - someProperty was set to false too early.
entity.setSomeProperty(false);

With FlowPoolAPI, this same logic would be:

// entity.someProperty is a `PoolToggle`

HandlerPool pool = new HandlerPool();
HandlerPool callbacksPool = new HandlerPool();

Runnable someCallback = () -> {
	entity.someProperty.push(callbacksPool);
	entity.doCalculation();
	callbacksPool.close(); // or entity.someProperty.pop(pool);
};

entity.someProperty.push(pool);
entity.doCalculation();
someCallback.run();
entity.doOtherCalculation(); // entity.someProperty is still true!
pool.close(); // entity.someProperty set to false

Notice how each state manipulator hold its own HandlerPool.
Alongside PoolToggle, there's PoolList and PoolStack for basic collections, and PoolPipeline for handler-based execution pipelines.

Find more about it in the wiki!

How do I use it?

Add the maven repo:

maven {
    name "teamcelestial-public"
    url "https://maven.teamcelestial.org/public"
}

And find the latest Gradle/Maven dependency here: https://maven.teamcelestial.org/#/public/me/thosea/flowpool/flowpoolapi
It requires Java 17 or higher.

Javadocs?

Find the javadoc link for your version on the release page: https://github.com/ItsThosea/flowpoolapi/releases

Thread safety?

None of these are thread-safe! You are responsible for enforcing thread safety yourself.

How'd you get the name?

An AI generated it.

About

Simple state-management library based around state manipulators holding objects to manage states.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages