That's a good question, and the solution is really clearđź‘Ť
I'm not sure I'd call the emit function a closure, it's not returning a function, and it's not being run outside it's lexical scope (although the callbacks are closures themselves I guess)
I am a full stack engineer, passionate about solving complex problems and collaborating with driven teams! I have 4+ years of experience working at small to mid sized startups.
That's a good question, and the solution is really clearđź‘Ť
I'm not sure I'd call the
emit
function a closure, it's not returning a function, and it's not being run outside it's lexical scope (although the callbacks are closures themselves I guess)Not the emit function - the event callbacks themself close over the
data
object and gain access to that themselves!