HomeWiki
HomeWiki
  1. Shopping Lists
  • Back to home
  • 1. Themes
  • Layout
    • New Layout
    • Legacy Layout
  • Components
    • Announcement
    • Banner Carousel
    • Banner With Products Carousel
    • Blog Category List
    • Blog List
    • Brand List
    • Brands Carousel
    • Breadcrumb
    • Call To Action
    • Cart
    • Categories List
    • Change Password
    • Checkout
    • Cookie Manager
    • Filter list
    • Footer
    • Forgot Password
    • Form
    • Hero Carousel
    • Icon Block
    • Invitation
    • Last Visited Products
    • Layout
    • Login
    • Map
    • Nav Bar
    • Offer
    • Product Attachments
    • Product Attributes
    • Product Documentation
    • Product Expected
    • Product Modal
    • Products Block
    • Products Carousel
    • Product Single
    • Profile
    • Quote
    • Register
    • Related Products
    • Search
    • Stores
    • Subscribe Newsletter
    • Text with Image
    • Top Bar
    • Video
  • Reusables
    • Getting Started
  • Assets
    • Getting Started
  • SDK
    • Products
      • _findProductsByCategory
      • _findProductsByIds
      • _findProductsByTitle
      • _findProductsByFilter
      • _findProductsByCriteria
      • _findProductsAndCalculate
      • _findProductsThenCalculate
      • _getProductAttributeSet
      • _setLastVisited
    • Categories
      • _findCategoryTreeById
      • _findCategoriesByIds
      • _findCategoryByAlias
      • _findCategoryTreeByAlias
      • _getCategoryContent
    • Collections
      • _getCollectionContent
      • _findCollectionsByIds
      • _findCollectionsByIdsThenCalculate
    • Brands
      • _getBrandContent
      • _findBrandsByIds
    • Cart
      • _addToCartMulti
      • _addToCart
      • _setCart
      • _clearCart
      • _setCartListener
      • _removeFromCart
      • _calculateCart
    • Checkout
      • _startCheckout
      • _updateCheckout
      • _completeCheckout
    • Shopping Lists
      • _getShoppingLists
      • _updateShoppingList
      • _createShoppingList
      • _deleteShoppingList
      • _getShoppingListByAlias
    • Navigation
      • _getFooterMenu
      • _getHeaderMenu
    • Users
      • _getUserById
    • Utils
      • _calculateCurrency
      • _getCurrencySymbol
      • _getCulture
      • _subscribeToNewsletter
      • _findUnitsByIds
  • Vs Code
    • Getting Started
  1. Shopping Lists

_updateShoppingList

Example Usage of _updateShoppingList Method#

The _updateShoppingList method is used to update an existing shopping list on the server. It sends the updated list data and processes the response using a callback function. Additionally, it emits an event to notify other parts of the application about the update.

Purpose#

To update a shopping list on the server and handle the updated list data through a callback function while notifying other parts of the application of the update.

Method Signature#

Parameters#

list (Object): An object representing the shopping list to be updated. It must include an alias property that specifies which shopping list to update and other properties to update.
Example:
callback (Function): A function to be executed with the updated shopping list data once the update is successful.

Usage Steps#

1.
Define a Callback Function:
Create a function that will process the updated shopping list data. This function will be called with the updated list data as its argument.
2.
Prepare the List Object:
Create an object representing the shopping list to update, including the alias and the updated data.
3.
Invoke the Method:
Call _updateShoppingList with the list object and the callback function.

Detailed Breakdown#

Data Update: Sends a PUT request to /api/ShoppingList/${list.alias} with the updated list data.
Event Emission: Emits an update-wishlist event with the updated shopping list data. This event can be used to update the UI or notify other components of the data change.
Callback Execution: Calls the provided callback function with the updated shopping list data.

Example#

Here's how you might use the _updateShoppingList method in your application:

Common Use Cases#

Editing Shopping Lists: Useful for scenarios where users can update the name, items, or other attributes of their shopping lists.
UI Synchronization: Helps in updating parts of the UI that display shopping list information to reflect changes immediately.
Data Integrity: Ensures that the latest version of the shopping list is stored on the server and used across different parts of the application.

Notes#

Event Subscription: Make sure that your application has handlers for the update-wishlist event if you're using it to trigger UI updates.
Error Handling: Consider adding error handling to manage scenarios where the update fails (though this example does not include error handling).
By following this documentation, you will be able to use the _updateShoppingList method to effectively update shopping lists in your application and manage related data changes.
Previous
_getShoppingLists
Next
_createShoppingList
Built with