rive-app / rive-ios

iOS runtime for Rive
MIT License
468 stars 53 forks source link

Rive iOS SDK Doesn’t Provide State Definitions for its State Machine States #257

Open rsaccone opened 1 year ago

rsaccone commented 1 year ago

Hello,

I am overriding the func stateMachine(_: didChangeState: ) method of the RiveViewModel in my derived class to learn of state changes as the animation progress especially to detect when the animation ends. I was expecting the library to provide constant definitions for the possible values of the didChangeState parameter. I didn’t find any such constants in the documentation and I had to search through the library source code and experiment to learn that the didChangeState value will be “ExitState” at the end of the animation I had to define a constant for the “ExitState” string in my application code and use it to compare against the didChangeState parameter to detect when the animation is complete. The library should make available constant definitions for these state strings along with documentation describing each possible state. Without that the library providing a unique constant definition that both the client and the library itself uses it sets up a situation where my application can break silently should the name of the state be modified in a library update since there is no one true definition.

mjtalbot commented 1 year ago

Hi @rsaccone thank you for bringing this up, definitely feels like we can do better here!