Appearance
useSyncWishlist
Definition
Composable for wishlist management.
Basic usage
ts
const {
items,
count,
getWishlistProducts,
addToWishlist,
removeFromWishlist,
clearWishlist
} = useLocalWishlist();
Signature
ts
export function useLocalWishlist(): UseLocalWishlistReturn
Return type
See UseLocalWishlistReturn
ts
export type UseLocalWishlistReturn = {
/**
* Get wishlist products from localstorage
*/
getWishlistProducts(): void;
/**
* Add product to wishlist by its id
*/
addToWishlist(id: string): Promise<void>;
/**
* Remove product from wishlist by its id
*/
removeFromWishlist(id: string): Promise<void>;
/**
* Remove all products from wishlist
*/
clearWishlist(): Promise<void>;
/**
* List of wishlist items
*/
items: ComputedRef<string[]>;
/**
* Count of wishlist items
*/
count: ComputedRef<number>;
};
Properties
Name | Type | Description |
---|---|---|
items | ComputedRef<Array<string>> | List of wishlist items |
count | ComputedRef<number> | Count of wishlist items |
Methods
Name | Type | Description |
---|---|---|
getWishlistProducts | void | Get wishlist products from localstorage |
addToWishlist | Promise<void> | Add product to wishlist by its id |
removeFromWishlist | Promise<void> | Remove product from wishlist by its id |
clearWishlist | Promise<void> | Remove all products from wishlist |