meteor

REACTIVITY

reactivity


In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change.

meteor reactivity


"Meteor embraces the concept of reactive programming. This means that you can write your code in a simple imperative style, and the result will be automatically recalculated whenever data changes that your code depends on."





-Meteor Docs

in other words...

Reactive Style Programming is about writing code that 
renders values when they are delivered

not code that 
retrieves values so they can be rendered.


DATA IS PUSHED, NOT PULLED.


-Dave Anderson 

in other other words...


Through code, you declare what to do with data

and don't have to declare what to do if the data changes.

the old observe



ObserveHandler(dataset){
  _.each(dataset, function(e){

    var elem = $('#elid-'+e.id);
    if (elem)
    {
      elem.text(e.text);
    }
    else{
      $('#elements').append(...)
    }

    // OH CRAP! I forgot about deletes...
  });
} 

The New observe


{{#each elems}}
    
{{text}}
{{/each}

Javascript "observe"

Deps.autorun(function () {
  Meteor.subscribe("counts-by-room", Session.get("roomId"));  //or....  return Session.get('somevalue');
}); 



Still observing

No longer being imperative / functional


MOAR!


https://www.discovermeteor.com/

http://docs.meteor.com

http://meteorhacks.com

Meteor Reactivity

By Isaac Strack

Meteor Reactivity

Quick walkthrough of reactivity in Meteor

  • 44

More from Isaac Strack