Skip to content
On this page

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 ​

NameTypeDescription
items
ComputedRef<Array<string>>
List of wishlist items
count
ComputedRef<number>
Count of wishlist items

Methods ​

NameTypeDescription
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
useSyncWishlist has loaded