pinafore/routes/_utils/once.js

9 lines
229 B
JavaScript
Raw Normal View History

2018-03-25 01:04:54 +00:00
// 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)
})
}