|
|
@ -4,20 +4,25 @@ export function set_current_component(component) {
|
|
|
|
current_component = component;
|
|
|
|
current_component = component;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_current_component() {
|
|
|
|
|
|
|
|
if (!current_component) throw new Error(`Function called outside component initialization`);
|
|
|
|
|
|
|
|
return current_component;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function beforeUpdate(fn) {
|
|
|
|
export function beforeUpdate(fn) {
|
|
|
|
current_component.$$.before_render.push(fn);
|
|
|
|
get_current_component().$$.before_render.push(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function onMount(fn) {
|
|
|
|
export function onMount(fn) {
|
|
|
|
current_component.$$.on_mount.push(fn);
|
|
|
|
get_current_component().$$.on_mount.push(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function afterUpdate(fn) {
|
|
|
|
export function afterUpdate(fn) {
|
|
|
|
current_component.$$.after_render.push(fn);
|
|
|
|
get_current_component().$$.after_render.push(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function onDestroy(fn) {
|
|
|
|
export function onDestroy(fn) {
|
|
|
|
current_component.$$.on_destroy.push(fn);
|
|
|
|
get_current_component().$$.on_destroy.push(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function createEventDispatcher() {
|
|
|
|
export function createEventDispatcher() {
|
|
|
@ -37,6 +42,14 @@ export function createEventDispatcher() {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function setContext(key, context) {
|
|
|
|
|
|
|
|
get_current_component().$$.context.set(key, context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function getContext(key) {
|
|
|
|
|
|
|
|
return get_current_component().$$.context.get(key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO figure out if we still want to support
|
|
|
|
// TODO figure out if we still want to support
|
|
|
|
// shorthand events, or if we want to implement
|
|
|
|
// shorthand events, or if we want to implement
|
|
|
|
// a real bubbling mechanism
|
|
|
|
// a real bubbling mechanism
|
|
|
|