As Task.jsm is used more throughout our code it would be good to try to use
similar sorts of patterns to avoid confusion.

One difference I've spotted is in how to write asynchronous functions that
are called by tasks. One way is to simply write the function as a
generator, the other is to write the function as something that returns a
promise by wrapping its code with another Task.spawn call. In both cases
the calling task just yields the result of the function to wait for it to
complete.

I'm going to claim that the latter method of returning a new task promise
is the one we should use in general. It makes the function more easily
usable outside of a task since you're just getting a promise back. It is
also what Task.jsm does internally for generators anyway.

Does anyone disagree?
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to