microstates / ember

@microstates/ember - Official Microstates bindings for Ember.js
https://ember-microstates.netlify.com
MIT License
70 stars 12 forks source link

too much recursion when calling a custom transition #172

Open vitch opened 5 years ago

vitch commented 5 years ago

An example is worth a thousand words so I put together a reproduction: https://codesandbox.io/s/microstates-jgdhu

I sum up the issue in the comments there but basically calling a custom transition on a microstate is causing an infinite recursion error. I think because the action in question is still pointing to a previous revision of the microstate. But I'm not sure how to avoid this happening or if Glimmer should have known to re-compute the action when the state was updated?

vitch commented 5 years ago

To be more explicit in case the code sandbox is unavailable, given the following setup:

https://gist.github.com/vitch/d8edb1b5d4895daf944cf5f086454d28

Where tabManager is {{#let (state (type "tab-manager") this.model) as |tabManager|}} the following code works once:

onclick={{action tabManager.activateTab tab}}

But running it a second time fails - I think because tabManager in the action is still pointing to the original instance of the microstate while it should have been updated to the new microstate...