Appearance
useWishlist ​
Definition ​
Composable to manage wishlist
Basic usage ​
ts
const {
items,
getCurrentPage,
getTotalPagesCount,
totalWishlistItemsCount,
mergeWishlistProducts,
getWishlistProducts,
clearWishlist,
changeCurrentPage
} = useWishlist();
Signature ​
ts
export function useWishlist(): UseWishlistReturn
Return type ​
See UseWishlistReturn
ts
export type UseWishlistReturn = {
/**
* Merge products with wishlist between async (API) and sync (localstorage) wishlists
*/
mergeWishlistProducts(): void;
/**
* Get products list added to wishlist
*/
getWishlistProducts(): void;
/**
* Clear wishlist
*/
clearWishlist(): void;
/**
* Wishlist items (Product IDs)
*/
items: ComputedRef<string[]>;
/**
* Changes the current page number
* @param pageNumber - page number to change to
* @returns
*/
changeCurrentPage(page: number, query?: Schemas["Criteria"]): Promise<void>;
/**
* Current page number
*/
getCurrentPage: ComputedRef<number>;
/**
* total pages count
*/
getTotalPagesCount: ComputedRef<number>;
/**
* total wishlist items count
*/
totalWishlistItemsCount: Ref<number>;
};
Properties ​
Name | Type | Description |
---|---|---|
items | ComputedRef<Array<string>> | Wishlist items (Product IDs) |
getCurrentPage | ComputedRef<number> | Current page number |
getTotalPagesCount | ComputedRef<number> | total pages count |
totalWishlistItemsCount | Ref<number> | total wishlist items count |
Methods ​
Name | Type | Description |
---|---|---|
mergeWishlistProducts | void | Merge products with wishlist between async (API) and sync (localstorage) wishlists |
getWishlistProducts | void | Get products list added to wishlist |
clearWishlist | void | Clear wishlist |
changeCurrentPage | Promise<void> | Changes the current page number |