The function invokes as an IIFE and is exposed in global scope (i.e, window.wishlist
or simply, wishlist
). This means that you simply drop it in via <script>
. It provides several methods for usage. By default, it will not do anything until you wire it up. Firstly, let me explain the main methods:
// use render method to optionally create a virtual wishlist, more on this later
wishlist.render((product) => `<a href="#"><img class="img" src="${product.img}"></a>`);
// If you need to listen for wishes
wishlist.on('wished', (args) => console.log(args));