LoyaltyLion SDK
Live updating
The SDK doesn’t automatically observe our components or their inputs for changes. It’s up to you to implement an update flow that is appropriate for your use case.
If you have a dynamic cart, you may have some function that runs when the cart updates. Or in some other cases you may have be dynamically creating or removing the span above as the user navigates your page. Regardless of your approach, the SDK supports a function that refreshes the page as necessary:
If the component has been removed after pageload and is then re-added
- Render the component to the screen
- call
window.loyaltylion.ui.refresh()
If the component’s value needs to be updated
- Update the component’s attribute value
- call
window.loyaltylion.ui.refresh()
Example
Let’s say you have a span showing the points for cart for the initial cart total:
And you have some dynamic cart functionality (note: intended to illustrate flow and order of events only, your dynamic page content code likely looks different):