1.0.0 • Published 3 years ago

senp v1.0.0

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

Senp is a very simple reactive library based on triggers. It was inspired by this article and is heavily focused on it.

npm.io

⚙️ How to use?

One of the most simple yet useful example is changing the value of an element based on click. To do this, you need an html template like this:

    <script src="https://cdn.jsdelivr.net/gh/KauanRakoski/Senp/src/index.js"></script>

    <div id="app">0</div>
    <button onclick="Handleclick()">Click me!</button>

And a simple script, that tells the div content to change when the value changes:

    let div = document.getElementById('app')

    const Num = Trigger({
            state: 0
        })
        
    Num.observe('state', ()=> {div.innerHTML=`${Num.data.state}` })

    function Handleclick(){
        Num.data.state += 1
   }

   // You can substitute Num.observe by watch node
   WatchNode(div, Num, 'state')