0.1.1 • Published 8 years ago

buni v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

buni

A tiny and uni-directional data binding library

Usage

<!-- HTML -->
<div id="wrapper">
  <!--
    Bind text value to value attribute
    and listen input event by onInput handler
  -->
  <input type="text" :value="text" @input="onInput">

  <!-- Bind text value to its child content -->
  <span $="text"></span>
</div>
// JavaScript
import { bind, unbind } from 'buni';

const wrapper = document.getElementById('wrapper');

// Bind data to DOM elements and return bound data
const boundData = bind(wrapper, {
  text: 'Input text',
  onInput: function(event) {
    this.text = event.target.value;
  }
});

// Unbind
const unboundData = unbind(boundData);

License

MIT

0.1.1

8 years ago

0.1.0

8 years ago