LevelbossMike / ember-statecharts

Statecharts for Ember.js applications
https://ember-statecharts.com/
MIT License
72 stars 13 forks source link

Why "useMachine" does not work on a service? #397

Closed phcoliveira closed 1 year ago

phcoliveira commented 1 year ago

Hello there!

I understand that the usage of useMachine on a component is useful for not handling these steps: interpreting, starting the machine, subscribing, updating the state and stopping the machine once the component is destroyed.

But why should it not be possible to do it on a service as well? Yeah, the service is a long-lived singleton that does not get destroyed. But all the other steps before mentioned are still a valid concern to address.

Is there a technical reason for not performing such steps on a service?

phcoliveira commented 1 year ago

Or a controller, if also not possible.

phcoliveira commented 1 year ago

False alarm. It does work with a controller. I just didn't invoke inspect before the service was initialized.