1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00
budibase/packages/client/src/utils/getAction.js

20 lines
446 B
JavaScript

import { get } from "svelte/store"
import { getContext } from "svelte"
/**
* Gets a component action.
* @param id The component ID that provides the action
* @param type The action type to get
* @returns {null|*} The action function
*/
export const getAction = (id, type) => {
if (!id || !type) {
return null
}
const context = getContext("context")
if (!context) {
return null
}
return get(context)?.[`${id}_${type}`]
}