[lib] now uses an event emitter