Pinafore-Web-Client-Frontend/src/routes/_utils/once.js

9 lines
229 B
JavaScript
Raw Normal View History

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