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

ember/no-runloop #2079

Open
amk221 opened this issue Jan 29, 2024 · 4 comments
Open

ember/no-runloop #2079

amk221 opened this issue Jan 29, 2024 · 4 comments

Comments

@amk221
Copy link
Contributor

amk221 commented Jan 29, 2024

Would it be possible to improve the docs around ember/no-runloop?

  • Fresh ember-cli apps use @ember/runloop in instance initializer tests.
  • The readme talks about async cleanup, but there are so many more features in there, like
    scheduleOnce('afterRender'... and, debounce, etc.
  • Its necessary to wrap code in run in order for ember/test-helpers setupOnerror/resetOnerror to work.
@NullVoxPopuli
Copy link
Contributor

Fresh ember-cli apps use @ember/runloop in instance initializer tests.

this is probably a bug and the tests should be updated 😅

The readme talks about async cleanup, but there are so many more features in there,

like more alternatives to things you listed?
I imagine it'd be a bit situational -- and in some cases not needed?
but maybe having a few examples would be good -- more examples never hurts.

Its necessary to wrap code in run in order for ember/test-helpers setupOnerror/resetOnerror to work.

It is not

setupOnError can happen pre-visit, pre-render, and resetOnError, I usally do after every test so I don't forget about it.

https://github.com/NullVoxPopuli/limber/blob/main/apps/repl/tests/test-helper.ts#L22

@amk221
Copy link
Contributor Author

amk221 commented Jan 29, 2024

Thanks :)

For this one:

Its necessary to wrap code in run in order for ember/test-helpers setupOnerror/resetOnerror to work.

emberjs/ember-test-helpers#1128

In order for setupOnerror to work, the code that throws needs to be in a run.

@NullVoxPopuli
Copy link
Contributor

if you don't want code in a run, you could use window.addEventListener('error'? perhaps?

using run at all is some api leakage 😅

@amk221
Copy link
Contributor Author

amk221 commented Jan 29, 2024

setupOnerror doesn't work with window.addEventListener though? Anyway, that's off topic. My point is, there are reasons to use the @ember/runloop (and therefore ignore the eslint warning). At this moment in time.

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

No branches or pull requests

3 participants