buni

0.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i buni

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • ktsn