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
| 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 |
| Method | Description |
|---|---|
| getAllProducts() | Get products |
| getProduct(product) | Get product by id |
| updateProduct(product) | Fetches most up to date |