Handlebars is one of the most popular templating engines. Complicated UIs, data visualizations, and systems of calculations are examples of just a few problems where organising code becomes really hard while updating the templates on change.
See this Demo
Read this article
bower install reactive-handlebars
npm install reactive-handlebars
Counter Example
let counter = new ReactiveHbs({
container: '.mount',
template: '#tpl',
data: {
count: 0
}
});
counter.helpers({
multiplyByTwo() {
return counter.get('count') * 2;
}
});
counter.events({
'click [name="increment-count"]': (e, elm, tpl) => {
tpl.set( 'count', tpl.get('count') + 1 );
}
});
counter.reactOnChange('count', { throttle: 100 }, (tpl) => {
console.log('count have been changed ', tpl.get('count'));
});
// turn the observer off when not needed
counter.stopReactOnChange('count');
Check out these examples in the wild