A
AlokaiPavelBrimit

Composable

How to use methods from one composable (for example method clear in useCart) in another composable (useUser)?
S
skirianov377d ago
following the usual Vue pattern should work
import { ref } from 'vue';
import useFirstComposable from './useFirstComposable';

export default function useSecondComposable() {
const { count, increment, doubledCount } = useFirstComposable();
const message = ref('Hello from the second composable!');

const resetCount = () => {
count.value = 0;
};

return {
message,
count,
increment,
doubledCount,
resetCount
};
}
import { ref } from 'vue';
import useFirstComposable from './useFirstComposable';

export default function useSecondComposable() {
const { count, increment, doubledCount } = useFirstComposable();
const message = ref('Hello from the second composable!');

const resetCount = () => {
count.value = 0;
};

return {
message,
count,
increment,
doubledCount,
resetCount
};
}
generally, I would not recommend it, in case if a method involves fetching but possible
P
PavelBrimit375d ago
@skirianov Thanks for your reply, but when I'am trying to use one composable in another I got an error.
S
skirianov375d ago
@Pavel I was expecting something like this tbh -_- Yeah, you can't call the composable like this, this is the limitation of composition api package I suppose. You will have to do it one by one in the setup method
P
PavelBrimit375d ago
Got it, thanks!
Want results from more Discord servers?
Add your server
More Posts
Style repeated for every componentHi there, in my inspect tool I notice that style il repeated for every component. Is it normal behavAdding a custom API callWe are trying to create a Business unit upon the creation of the new user for that we have created aGlide.js is treated as an ES moduleHi, i get this error after running `yarn start` and trying to access the page Does anyone know howtranslating componentsI cannot find a way to translate the SfAddToCart button's label. How can I do that?How is checkout components rendering?In code i find this array of steps in checkout. But how i can, for example, change component for shiUnable to make API call on serverhttps://auction-dev.ycspl.in/weeklyauction while accessing this endpoint my network request is made issue with API callWhen I do yarn start it adds undefined to my request url but when I do yarn dev it works fine. Can ygetting this error while trying to deployjenkins@ip-172-31-24-212:~/workspace/auction-frontend$ npm install npm WARN read-shrinkwrap This verUnable to access cookies in composablescontext.$bagisto.config.app.$cookies.set('vsf-bagCust-token', loginResult.data.api_access_token); myVSF UI 2 with ecommerce-integration-boilerplateHi, I hope this isn't a silly question :). Is it possible to use the new UI with the boilerplate fouWhat version of Node?Noob question. I was trying to create a storefront with spree and got the following error: error @vuHow to add custom function to a composableimport { Context, useFacetFactory, FacetSearchResult } from '@vue-storefront/core'; import typGet product details and Static block from magento 2 backend to VueStoreFront.Hi, I have a doubt. I need to call static block from magento to vuestorefront homepage someone pleasPossible Memory leak in vuestorefront-apiHi, we are using vuestorefront 1, problem we facing at the moment is that with time the api server i