uvjs
v0.1.4
Published
Small reactive library for class bindings, events and actions.
Downloads
8
Readme
UV
Small reactive library for class bindings, events and actions.
Install & import
You can use UV in many different ways. If you're not using UV as an NPM package you can find bundles (with bundled dependencies) in the dist
folder of this repository.
NPM package
yarn add uvjs
# or
npm install uvjs --save
import uv from 'uvjs'
Native module
import uv from './dist/uv.module.js'
Browser global
<script src="dist/uv.browser.js"></script>
Usage
Initialize
const app = new uv({
isRaining: false,
hasMoon: true
})
Bind element classes to props
app.bind('.sky', {
raining: () => app.isRaining
})
Bind events/actions to elements
app.on('.toggle', 'click', () => {
app.isRaining = !app.isRaining
})
app.on('.sky', 'scroll', scrolled => {
app.hasMoon = scrolled < 400
})
Watch props
app.watch('hasMoon', val =>
console.log('Moon is now ' + val)
)