Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition.data not kept across transition retry #325

Open
Techn1x opened this issue Jul 29, 2021 · 0 comments
Open

transition.data not kept across transition retry #325

Techn1x opened this issue Jul 29, 2021 · 0 comments

Comments

@Techn1x
Copy link

Techn1x commented Jul 29, 2021

Hi! I'm trying to make use of transition.data to keep a count of transition retries. Something like the following;

// application route
@action
error(error, transition) {
  if (error.retryable) {
    const transitionData = transition.data || {}
    const { retryCount = 0 } = transitionData

    if (retryCount < 3) {
      transition.data = { ...transitionData, retryCount: retryCount + 1 }
      transition.retry()
    } else {
      // some other remedy
    }
  }
}

Unfortunately, it seems what I set in transition.data is forgotten when the transition is retried - if that retried transition fails and re-enters the error hook, retryCount is gone. The Ember docs specifically mention that this should work https://api.emberjs.com/ember/3.27/classes/Transition/properties/data?anchor=data

Properties set on data will be copied to new transitions generated by calling retry on this transition


As a workaround, I have found that I can set transition.intent.data and it remembers it across the retry. Though I am not sure of the implications of doing that (if any)

It might be related to #77 though that issue seems very old!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant