Legitimate uses of IIFEs?

Andrea Giammarchi andrea.giammarchi at gmail.com
Sun Dec 20 22:42:17 UTC 2015


I'm trying to figure out how worlds based on current modules ecosystem
would work ...

```js
let
  path = require('path'),
  lib = require(path.join(__dirname, 'lib/index.js'))
;
```

How even in an ES2015 world would that look like?

Putting async/await everywhere doesn't seem like a real answer ... or does
it?




On Sun, Dec 20, 2015 at 10:07 PM, Fabrício Matté <ultcombo at gmail.com> wrote:

> On Sun, Dec 20, 2015 at 7:32 PM, <bread at mailed.me.uk> wrote:
>
>> there is no reason to create an async function to invoke another async
>> function; one can simply invoke it, and if the result/completion is
>> required, use it's ,then() member....but there's no need/advantage to
>> wrapping such an invocation in an IIAFE, right?
>
>
> I believe the advantage is that you can then replace the
> `.then(onFulfilled, onRejected)` constructs with `await/try/catch`, thus
> simplifying the code and improving readability. I recognize this may be an
> uncommon pattern though, as most often the caller of an async function will
> be an async function as well. Note that I say "uncommon" referring to async
> IIFEs inside non-async functions; async IIFEs are still very useful to
> parallelize sequences of async operations as I've mentioned before.
>
> Btw, the term "IIAFE" should probably be avoided, as the "A" can
> ambiguously mean "Arrow" or "Async".
>
> /fm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151220/5eb06ae3/attachment-0001.html>


More information about the es-discuss mailing list