0.0.1 • Published 9 years ago

nwjs-bindings v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

nwjs-bindings

Fast, native and simple two-way data binding for nwjs apps

description

nwjs-bindings is a pluggable, fast, native and minimal two-way data binding solution for node-webkit applications. I created nwjs-bindings out of frustration of having to use bloated non-native libraries like emberjs, knockoutjs, backbone, angularjs for simple two-way data binding.

nwjs-bindings uses Object.observe which has been available since Chrome 36 stable which means it uses native data binding. nwjs-binding is purely vanilla javascript with no bloat which means no jQuery or other 3rd party modules.

installation

npm install -g matadoer/nwjs-bindings

quick start

binding a js object to a DOM object

js

var nwbind = require('nwjs-bindings');

//create a test object that contains a key value with a string
var testObject = {
  test: 'holy bindings, batman!'
}

//bind testObject to the entire document (you can bind objects to individual elements like divs)
nwbind.bind(document, testObject);

in the DOM, the data-bind attribute is where the magic happens. for any input you can simply use the input binding preceding the object key you want to bind. for simple strings you can use the text binding, or for counting the characters in strings the library comes with a count binding.

html

<input data-bind="input test" />
<br />
<p>'<span data-bind="text test"></span>' has <span data-bind="count test"></span> characters</p>

when you type in the input field, the spans tags will automagically update!