adamhaile / S

S.js - Simple, Clean, Fast Reactive Programming in Javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamic Updating

arthurgeron opened this issue · comments

So, does S.js automatically watches for changes on S objects inside DOM?
For example, I believe something like this should work:

var icon = 'fas fa-check'
var iconData = S.data(icon)

const loggedInLabel = S.root(() =>
  <label class={iconData()}/>
)
document.body.appendChild(loggedInLabel)
setTimeout(() => {icon = 'fas fa-cross'}, 1000)

But even if I assign the value of iconData again after changing the value of icon the DOM doesn't update. What am I doing wrong?

Found out what I was doing wrong, should've updated iconData by calling: iconData(newValue) instead of a manual way.