UNPKG

data-binding

Version:

Data attribute binding and interpolation

46 lines (43 loc) 1.09 kB
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Simple Live binding</title> </head> <body> <!-- because binding read and trigger error on script...advanced expression :s --> <div class="section"> <h3 class="title">There is <span>{{number}}</span> connected users.</h3> <p> with the id : <span>{{group}}group{{number}}</span> </p> <a href="/ids/{{number}}">{{id}}</a> <p> And there is {{group}} groups of 2 users. </p> </div> <script src="../build/build.js"></script> <script> var Binding = require('binding'); var Store = require('datastore'); var index = 2; var group = 0; var store = new Store({ number: index }); console.time('olivier'); var binding = new Binding(store); binding.scan(document.querySelector('.section')); store.compute('id', function(){ return this.group + '' + this.number; }); console.timeEnd('olivier'); setInterval(function(){ store.set('number', ++index); if(index%2){ store.set('group', ++group) } }, 10); </script> </body> </html>