N
Nuxt3mo ago
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)
};
}
1 Reply
Cue
Cue3mo ago
Seems normal
Want results from more Discord servers?
Add your server