ember-concurrency icon indicating copy to clipboard operation
ember-concurrency copied to clipboard

Should being able to do a .then on the result of a .perform be doc'd?

Open SirZach opened this issue 8 years ago • 4 comments

I randomly tried doing a .then on the execution of a task and was pleasantly surprised it worked. I couldn't find documentation on it which makes me worried that it might go away.

SirZach avatar Jan 06 '17 18:01 SirZach

This functionality is here to stay, as it is very important for interop with the rest of the non-Task world.

I suppose we could improve the docs surrounding this functionality but I'd worry that people would start using someTask.perform().then(() => {...}) from within another task function, which is bad because .then() in a task function is often an anti-pattern and anything you yield that has a .then() can't be cancelled immediately in the same way tasks can.

machty avatar Jan 06 '17 19:01 machty

My use-case was having the code that performed the task be reusable in the model hook but I couldn't make the model hook a task

SirZach avatar Jan 06 '17 19:01 SirZach

@SirZach that sounds like a perfectly reasonable use case to add to the docs 👍

machty avatar Jan 06 '17 19:01 machty

Cool, I'll try and spin up PR this weekend to document it. Thanks!

SirZach avatar Jan 06 '17 19:01 SirZach