mirror of
https://github.com/nolanlawson/pinafore
synced 2024-12-11 09:45:24 +01:00
9 lines
229 B
JavaScript
9 lines
229 B
JavaScript
// svelte helper to add a .once() method similar to .on, but only fires once
|
|
|
|
export function once (eventName, callback) {
|
|
let listener = this.on(eventName, eventValue => {
|
|
listener.cancel()
|
|
callback(eventValue)
|
|
})
|
|
}
|