Store API - cshub-yorku/merchStore GitHub Wiki

Store API is implemeted using Context hook and acts as a collection of states, variables and methodes that implements different systems within the app.

Context object can be accessed using custom hook useStoreContext(). You can use this object and any other object litteral in js.

example would be following piece of code

export  default  function  exampleFunction()  {

        const cart = useStoreContext();

	return (
		<Button onClick={() => { cart.addItem(product) }}>
	)
}

Table of contents

  1. Cart
  2. Product

Cart

Method Description
addItem(product) Stores and saves product object
NOTE! product MUST contain id property
removeItem(produc) Removes product object from local and remote storage
NOTE! product MUST contain id property
getAllItems() Returns map of items in cart

Product

Method Description
getAllProducts() Get products
getProduct(product) Get product by id
updateProduct(product) Fetches most up to date
⚠️ **GitHub.com Fallback** ⚠️