
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
=Events::Emitter {<img src=https://travis-ci.org/matsadler/rb-event-emitter.png>}[http://travis-ci.org/matsadler/rb-event-emitter]
The Events::Emitter mixin provides a clone of the Node.js EventEmitter API for Ruby.
Instances of classes including Events::Emitter will emit events, events are represented by symbols, underscored in the usual Ruby fashion. Examples: :connection, :data, :message_begin
Blocks can be attached to objects to be executed when an event is emitted, these blocks are called listeners.
All EventEmitters emit the event :new_listener when new listeners are added, this listener is provided with the event and new listener added. Example: server.on(:new_listener) do |event, listener| puts "added new listener #{listener} for event #{event}" end
server.on(:connection) do |socket| puts "someone connected!" end Outputs "added new listener #Proc:0x0000000000000000@example.rb:12 for event connection".
==Events::EventEmitter
The Events::EventEmitter class is provided as a convenience for those who wish to inherit from a class. It simply includes the Events::Emitter module.
==Methods
emitter.on(event, &block)
Adds a listener to the end of the listeners array for the specified event. server.on(:connection) do |socket| puts "someone connected!" end
emitter.once(event, &block)
Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed. server.once(:connection) do |socket| puts "Ah, we have our first user!" end
emitter.remove_listener(event, proc)
Remove a listener from the listener array for the specified event.
emitter.max_listeners = n
By default an EventEmitter will print a warning if more than 10 listeners are added to it. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This method allows that to be increased. Set to zero for unlimited.
emitter.listeners(event)
Returns an array of listeners for the specified event. This array can be manipulated, e.g. to remove listeners.
emitter.emit(event[, arguments...])
Execute each of the listeners in order with the supplied arguments.
FAQs
Unknown package
We found that events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.