Skip to content

Instantly share code, notes, and snippets.

@shiftyp
Last active July 29, 2020 18:22
Show Gist options
  • Save shiftyp/8fa115b2e08c5c9ef36ed7c7acc086f9 to your computer and use it in GitHub Desktop.
Save shiftyp/8fa115b2e08c5c9ef36ed7c7acc086f9 to your computer and use it in GitHub Desktop.
Alternative Wicked API
wickedElements.define('.my-counter', (element, { events, changes, values }) => {
const counter = element.querySelector('.count')
const minus = element.querySelector('.minus')
const plus = element.querySelector('.plus')
changes(values).count(count => {
counter.textContent = count
})
values.count = 0
events(minus).click(() => values.count--)
events(plus).click(() => values.count++)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment