|
|
|
@ -155,7 +155,7 @@ function start_bubble(type: string, bubble: Bubble, callback: Callback) {
|
|
|
|
|
|
|
|
|
|
|
|
function start_bubbles(comp : SvelteComponent, bubble: Bubble) {
|
|
|
|
function start_bubbles(comp : SvelteComponent, bubble: Bubble) {
|
|
|
|
for (const type of Object.keys(comp.$$.callbacks)) {
|
|
|
|
for (const type of Object.keys(comp.$$.callbacks)) {
|
|
|
|
comp.$$.callbacks[type].forEach( callback => { start_bubble(type, bubble, callback); })
|
|
|
|
comp.$$.callbacks[type].forEach( callback => start_bubble(type, bubble, callback));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -186,8 +186,8 @@ export function add_callback(comp : SvelteComponent, type: string, f: EventListe
|
|
|
|
const callback: Callback = {f, o};
|
|
|
|
const callback: Callback = {f, o};
|
|
|
|
|
|
|
|
|
|
|
|
if (o && (o as any)?.once === true) {
|
|
|
|
if (o && (o as any)?.once === true) {
|
|
|
|
callback.f = function () {
|
|
|
|
callback.f = function(this: any, ...args) {
|
|
|
|
const r = f.apply(this, arguments);
|
|
|
|
const r = f.call(this, ...args);
|
|
|
|
remove_callback(comp, type, callback);
|
|
|
|
remove_callback(comp, type, callback);
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -236,9 +236,14 @@ function add_bubble(comp: SvelteComponent, type: string, f: CallbackFactory): Fu
|
|
|
|
for (const dispose of bubble.r.values()) {
|
|
|
|
for (const dispose of bubble.r.values()) {
|
|
|
|
dispose();
|
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Schedules a callback to run when an handler is added to the component
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* TODO : Docs
|
|
|
|
|
|
|
|
*/
|
|
|
|
export function onEventListener(type: string, fn: CallbackFactory) {
|
|
|
|
export function onEventListener(type: string, fn: CallbackFactory) {
|
|
|
|
add_bubble(get_current_component(), type, fn);
|
|
|
|
add_bubble(get_current_component(), type, fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|