Mobject-Dev-Team / mobject-core

This is the combination of core libraries of mobject
MIT License
2 stars 0 forks source link

Modify state properties/behaviour #2

Open piratecarrot opened 9 months ago

piratecarrot commented 9 months ago

Currently, there are four properties, Busy, Done, Aborted and Error. To determine that a command has been executed but hasn't finished, there doesn't seem to be any way of doing that. Busy can't be used because it is false prior to the execute command being run.

An idea is to change the properties to Idle, Executing, Done. These three states tell you what you can do with a command. Idle can be started, Executing can be aborted and Done can fetch results. Then in the Done state, have Result, which can be, Ok, Aborted or Error. Result would be a struct or an object with an enum of the three possibilities and an error Id. This makes it easy to use with a case statement. I am looking at Rust here with its enum pattern matching for inspiration in terms of code style. This isn't required of course and if statements against booleans would suffice.

Be interested to know your thoughts.

piratecarrot commented 9 months ago

There is an example in the dev branch of my forked repository if you would like to have a look. It includes some sweet ascii art state charts to show the state machine that was already implemented, and a diagram illustrating how those states map to the new properties indicating what the command is doing. There has also been I_Result created which allows the retrieval of the result which can be dealt with after the command has been destroyed.

benhar-dev commented 5 months ago

moved from mobject-command to mobject-core