文件名称:双向数据绑定JS库Bindable.js.zip
文件大小:148KB
文件格式:JS
更新时间:2022-08-07 01:07:45
开源项目
Bindable.js 实现了灵活、快速的双向数据绑定的 JavaScript 库。 Two-way data binding means linking properties of two separate objects - when one changes, the other will automatically update with that change. It enables much easier interactions between data models and UIs, among other uses outside of MVC. Bindable.js is similar to Ember's data-binding system, except it doesn't include anything View related, so the library has many use-cases - whether replacing Backbone's Model, providing a way to maintain the state between server <-> client for a realtime front-end application (similar to Firebase), or perhaps a way to communicate between server <-> server for a realtime distributed Node.js application. Projects using bindable.js Paperclip.js - data-bindable templating engine. Sherpa.js - online tours library Mojo.js - javascript MVC framework. AWSM - aws library. ditto - synchronized user interactions across browsers. 示例代码: var bindable = require("bindable"); var person = new bindable.Object({ name: "craig", last: "condon", location: { city: "San Francisco" } }); person.bind("location.zip", function(value) { // 94102 }).now(); //triggers the binding person.set("location.zip", "94102"); //bind location.zip to another property in the model, and do it only once person.bind("location.zip", { to: "zip", max: 1 }).now(); //bind location.zip to another object, and make it bi-directional. person.bind("location.zip", { target: anotherModel, to: "location.zip", bothWays: true }).now(); //chain to multiple items, and limit it! person.bind("location.zip", { to: ["property", "anotherProperty"], max: 1 }).now(); //you can also transform data as it's being bound person.bind("name", { to: "name2", map: function (name) { return name.toUpperCase(); } }).now(); 标签:Bindable
【文件预览】:
bindable.js-master
----.travis.yml(94B)
----benchmark()
--------index.js(3KB)
----package.json(1KB)
----test()
--------event-emitter-test.js(3KB)
--------object-bind-multiple-test.js(807B)
--------watching-test.js(7B)
--------context-test.js(1KB)
--------transform-test.js(7KB)
--------object-bind-computed-test.js(3KB)
--------pause-resume-test.js(2KB)
--------collection-test.js(6KB)
--------object-basic-test.js(6KB)
--------object-bind-test.js(3KB)
----browser()
--------bindable.js(72KB)
----.npmignore(0B)
----makefile(917B)
----MIT-LICENSE.txt(1KB)
----.gitignore(32B)
----lib()
--------collection()
--------core()
--------index.js(331B)
--------object()
--------utils()
----jshint.json(20B)
----README.md(6KB)
----coverage()
--------lcov.info(9KB)
--------lcov-report()
--------coverage.json(49KB)