November 2017
— The "pro" here is that it avoids mutating stateThe 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://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
— You'd have to pass the once: true property in the options argument
once: true
— So for browsers, it would look like:
entryEmitter.addEventListener('entry', function (entry) { // ...}, { once: true });