Message from JavaScript discussions

November 2017

— The "pro" here is that it avoids mutating state
The con is that this STILL isn't a pure functional monadic interface

Message permanent page


For two reasons:
.once is a side effect (mutates internal state of the event emitter)
res.end is not wrapped in a monadic type (like a promise)

— Is once an actual js function

— I can't find the MDN reference

— No

— Part of nodejs

— But browsers have the equivalent I believe

— Give me a sec

— Well, almost

— Https://

— You'd have to pass the once: true property in the options argument

— So for browsers, it would look like:

entryEmitter.addEventListener('entry', function (entry) {
// ...
}, { once: true });

Message permanent page