Closed ayanyev closed 6 months ago
A small change can help
override suspend fun processEvent(event: Event, argument: Any?): ProcessingResult {
return coroutineAbstraction.withContext {
checkNotDestroyed()
check(isRunning || **event is DestroyEvent**) { "$this is not started, call start() first" }
Hi! The fact that you cannot effectively call destroy()
on stopped StateMachine is a bug.
It was possible on older library versions but it was broken when I moved destroy()
method to event-processing mechanism. And missed such case.
As a workaround you can try using start() + destroy()
combination in Activity::onDestroy().
I will check how I can fix this and make destroy()
working on stopped StateMachine.
Thank You!
consideration: object/singleton events are released and can be reused
I suppose you meant States (not Events)
Actually, in your usecase you don't have to use destroy()
in Activity::onDestroy().
As createStateMachine()
has autoDestroyOnStatesReuse
argument. But looks it is broken for the same reason, as implemented through same destroy()
call.
Ha! This might be the reason as well
I tried to tie state machine to Android lifecycle:
But failed because stop() causes that DestroyEvent is not handled. And it is not clear, how can I call only destroy() without stop() if they bound to callbacks.
I know about stop parameter in destroy() but it is useless it in my case.
Any thoughts? May be I misuse these calls?