Rawdecky
Composables - good practices
Is it ok to structure a composable API like this? Are there any downsides? (look on return block)
export default function useDialogHelpers() {
const store= useStore();
const setSpinnerVisibility = (isVisible: boolean) => {
store.isSpinnerVisible = isVisible;
};
const setDialogVisibility = (isConfirmVisible: boolean, isContentVisible: boolean) => {
store.isVisibleConfirmDialog = isConfirmVisible;
store.isVisibleConfirmDialogContent = isContentVisible;
};
return {
showSpinner: () => setSpinnerVisibility(true),
hideSpinner: () => setSpinnerVisibility(false),
showConfirmDialogAndContent: () => setDialogVisibility(true, true),
hideConfirmDialogAndContent: () => setDialogVisibility(false, false)
};
}
export default function useDialogHelpers() {
const store= useStore();
const setSpinnerVisibility = (isVisible: boolean) => {
store.isSpinnerVisible = isVisible;
};
const setDialogVisibility = (isConfirmVisible: boolean, isContentVisible: boolean) => {
store.isVisibleConfirmDialog = isConfirmVisible;
store.isVisibleConfirmDialogContent = isContentVisible;
};
return {
showSpinner: () => setSpinnerVisibility(true),
hideSpinner: () => setSpinnerVisibility(false),
showConfirmDialogAndContent: () => setDialogVisibility(true, true),
hideConfirmDialogAndContent: () => setDialogVisibility(false, false)
};
}
2 replies