necolas / emitter.js Goto Github PK
View Code? Open in Web Editor NEWA simple JavaScript event-emitter
License: MIT License
A simple JavaScript event-emitter
License: MIT License
Should probably clean up and not leave the wrapped function attached to the callback once it's been removed.
let me explain the idea by taking an example:
says i have a event which called 'ready', it fires when my object is ready.
After the event is fired, that means my object will stay "ready" forever,
so i also would like to make sure, later if any callback gets added to 'ready' event, it gets called directly with the arguments previously emitted.
obj.reemit('ready',1,2,3);
obj.on('ready', function callback(){ console.log(arguments);});
// output "[1, 2, 3]"
wouldn't it be cool?
https://github.com/necolas/emitter.js/blob/master/emitter.js#L223
I don't understand why you throw an error here. It should be ignored. The common use case for events is that an object triggers events and you can choose to listen to them. You're not required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.