@spearwolf/eventize
Advanced tools
Changelog
v4.0.0
(2024-07-22)
!! BREAKING CHANGES !!
Introduction of the new functional API
Previously, the Eventize API methods were assigned to the object as methods after calling eventize(obj)
This behavior has changed in 4.0.0: all eventize methods are now available as library exports in the functional variant:
import {
on,
once,
onceAsync,
off,
emit,
emitAsync,
retain,
retainClear
} from '@spearwolf/eventize';
| before | after |
|--------|-------|
| obj.on(..)
| on(obj, ...)
|
| obj.once(..)
| once(obj, ...)
|
| obj.emit(..)
| emit(obj, ...)
|
| obj.off(..)
| off(obj, ...)
|
| ... | ... |
There is still the option to inject the Eventize API as methods to the object (but this is no longer the default) by using:
eventize.inject(obj)
→ eventizedObj with eventize-api methods
eventize.extend()
method has been removed, howevernew (class extends Eventize {})()
Eventize
is still available and works in the same way as beforeIf you are using the syntax from the composition via inheritance example, you should now be using eventize.inject
directly:
import {eventize, type Eventize} from '@spearwolf/eventize'
export interface Foo extends Eventize {}
export class Foo {
constructor() {
eventize.inject(this);
}
}
Other API Changes
eventize()
function, but the Priority
object is no longer assigned here
Priority
is still available as a named export (only)Changelog
v3.4.2
(2024-06-01)
.onceAsync()
so that the type of the promise return value can be specified optionallyChangelog
v3.4.1
.retain()
and .retainClear()
now also optionally allow the specification of multiple eventsChangelog
v3.3.0
.onceAsync()
only the event names are accepted as parameters, no callback functions anymore (this makes no sense).retainClear()
method: clear a saved event