Reactivity

In Nijor, we can define reactive variables . Reactive variables are defined as properties of the window.nijor.reactiveVars object. You can use the syntax, window.nijor.reactiveVars['varname'] to create a reactive variable. To access the value of a reactive variable inside the template tag, use the {{varname}} syntax.

        
    
<template> <!--To fetch the value of a reactive variable within the Nijor template, use {{variable}} --> <!--Whenever the value of window.nijor.reactiveVars['count'] changes, the value of {{count}} will automatically change--> <button on:click="UpdateCount()">{{count}}</button> </template> <script> window.nijor.reactiveVars['count'] = 1; // window.nijor.reactiveVars is a special object which contains a key-value pair of reactive variables and their values. // Changes in values of reactive variables get reflected on the DOM only. function UpdateCount(){ window.nijor.reactiveVars['count']+=1; } </script>