11
I see in frameworks as Angular, Vue, React, the concept of reactivity.
I’m totally naive on the subject, and as far as I know, the concept of reactive programming is basically performing asynchronous data flow. A variable in any of these frameworks which I mentioned, turns out to be reactive, because as you update the controller/component, it changes the DOM.
But how does it really work? I inserted a snippet how I imagine a observable working, would be something of that kind consisting of reactivity?
var variavel = 1
function observable (){
setInterval(function(){
if(variavel == 1){
console.log('Do Nothing...')
} else console.log('Mudou!')
}, 1000)
}
function Usuario(){
setInterval(function(){
console.log('Usuario fez alguma ação que mudou a variavel')
variavel = 2
}, 5000)
}
Usuario()
observable()
Thanks for Edit, @Stormwind
– Jackson