SlideShare une entreprise Scribd logo
1  sur  29
METEOR
Robert Dickert
@rdickert
robertdickert.com
Build high quality real-time apps quickly
PART I: WHY METEOR?
What is Meteor?
• Full-stack JavaScript Framework
• Build tool
• Package system
• Real-time protocol - DDP
• Built on Node.js
• Currently integrates with Mongodb (others to follow)
DEMO
What we saw
• Instant dev environment
• A working base app
• Smart packages
• Hot code push
• Code can run on client, server, or both
• Mongo api can be used locally to access server
• Reactive templates
• Data kept updated to all connected browsers
• Session store local – maintained through hot code pushes
• easy deployment to meteor.com
• bundle for deployment to any node.js environment
So Why Meteor?
• Real-time (chat, dashboard, games, etc.)
• Rapid prototyping
• Productive
• Declarative
• All JavaScript
Further resources
• docs.meteor.com and blog.meteor.com
• Discover Meteor (book) – highly recommended
• Meteor Weekly (newsletter)
• Meteor 101 screencast (Naomi Seyfer)
• www.eventedmind.com
• IRC
• Google Groups
• Github
• win.meteor.com – for Windows users
Questions?
PART II: REACTIVITY
How does Meteor achieve live client-side updates?
Meteor Advanced Topics
• Goal: useful for both beginners and advanced users
• A lot of “magic” in Meteor
• Is Meteor the jQuery of web app development?
Abstraction debt?
• Meteor’s hidden parts are in plain view – just go look
• Great chance to pick something to research and share
with the group
What is Reactivity?
• Reactivity describes a declarative data flow through
which changes propagate automatically.
• i.e., Data/variables update automatically when their upstream
dependencies change.
• Spreadsheet is the typical example
Lamest Demo Ever: Excel
Meteor Computations
A computation contains a stored function to be rerun
whenever required. A function running inside a
computation is said to be running in a reactive context.
_func:
function () {
return Session.get(“a1”)+ 1;
} .stop()
.invalidate()
a Deps.Computation:
Step 1: Put functions in computations
To place any function fn in a computation:
Templates and template helpers are automatically put in
a computation by Meteor.
Code in fn is said to be running in a reactive context. In a
reactive context,
Deps.active===true
handle = Deps.autorun(fn);
Demo: computations
Reactivity Requirements
Meteor Reactivity requires two things:
1. Run your code in a reactive context (e.g., with
Deps.autorun()).
2. Use a reactive data source inside the computation.
Other data sources will not update reactively.
Built-in Reactive Data Sources
• Session.get(“key”)
• Collection.find({sel})
• Meteor.user()
• Meteor.userId()
• Meteor.status()
• <subscription>.ready()
• Meteor.loggingIn()
Or use one from an outside module
e.g. Iron Router’s Router.current()
Making a reactive data source
Why?
• Control what to reactively respond to
• Create a package with reactive API
• Better code organization (Session === global?)
• To really understand what you are doing
Reactive Data Source is In Charge
• <data source>.get(): Data source stores the current
computation in a list of dependencies.
• <data source>.set(): Data source calls the .invalidate()
method on each computation in its list.
Comp id=1
Comp id=2
Comp id=3
id=1
Id=2
Id=3
Reactive
Data Source
source.get()
Comp id=1
Comp id=2
Comp id=3
id=1
Id=2
Id=3
Reactive
Data Source
invalidate()
Registering dependencies Invalidating dependencies on change
Deps.Dependency object
To create a reactive data source:
• Create a new Deps.Dependency()
• Call its .depend() method to register a computation
• Call its .changed() method to invalidate all dependencies
_dependentsById:
.changed()
Computation {_id:1}
Computation {_id:2}
Computation {_id:3}
.depend()
Demo – make a reactive data source
Quiz: Will this update reactively?
Session.set('a', 1);
var x = Session.get('a')
Deps.autorun(function () {
console.log(x); //console logs 1
});
Session.set ('a', 2); //console logs ???
What we didn’t cover
• Cascading dependencies and Deps.flush()
• Cleanup and other implementation details.
• Other Meteor packages that play a part in full-stack
reactivity
• Spark/UI
• Publish/subscribe
• Events
• Observe and other callback-based mechanisms
• Remember, Deps works on the client only!
Resources
• robertdickert.com: Why Is My Meteor App Not Updating
Reactively?
• https://github.com/meteor/meteor/tree/devel/packages/de
ps
• www.eventedmind.com
Questions?
Other possible surprises
• Computations run the whole function
• You need to .stop() unneeded computations
• Deps does not run on the server
• Know the difference between this and other Meteor
packages that playa part in “full-stack reactivity”
• Spark/UI
• Publish/subscribe
• Events
• Observe and other callback-based mechanisms
The data source is in charge
1. Stores computations in Deps.Dependency instance
2. Decides when to register a dependency
(dependency.depend())
3. Triggers the .invalidate() method of every dependent
computation (dependency.changed()).
• B1 needs to be rerun over and over
• It needs to be rerun when A1 changes
 B1 is dependent on A1
• B1 is a computation (aka “reactive context”)
• A1 is a reactive data source
Meteor Features
• One language
• Database everywhere
• Latency compensation
• Full stack reactivity
• Hot code pushes
• Low-friction prototyping and deployment

Contenu connexe

Tendances

Addressing data plane performance measurement on OpenStack clouds using VMTP
Addressing data plane performance measurement on OpenStack clouds using VMTPAddressing data plane performance measurement on OpenStack clouds using VMTP
Addressing data plane performance measurement on OpenStack clouds using VMTP
Suhail Syed
 

Tendances (20)

Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
Lecture: MetaLinks
Lecture: MetaLinksLecture: MetaLinks
Lecture: MetaLinks
 
Deploying Microservice on Docker
Deploying Microservice on DockerDeploying Microservice on Docker
Deploying Microservice on Docker
 
Prometheus Training
Prometheus TrainingPrometheus Training
Prometheus Training
 
Azure Function Workflow
Azure Function WorkflowAzure Function Workflow
Azure Function Workflow
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark  - Demi Be...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark  - Demi Be...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7
 
Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...
Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...
Matthew Treinish, HP - subunit2sql: Tracking 1 Test Result in Millions, OpenS...
 
Prometheus (Microsoft, 2016)
Prometheus (Microsoft, 2016)Prometheus (Microsoft, 2016)
Prometheus (Microsoft, 2016)
 
Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7
 
Prometheus workshop
Prometheus workshopPrometheus workshop
Prometheus workshop
 
QTP Automation Testing Tutorial 5
QTP Automation Testing Tutorial 5QTP Automation Testing Tutorial 5
QTP Automation Testing Tutorial 5
 
MeetUp Monitoring with Prometheus and Grafana (September 2018)
MeetUp Monitoring with Prometheus and Grafana (September 2018)MeetUp Monitoring with Prometheus and Grafana (September 2018)
MeetUp Monitoring with Prometheus and Grafana (September 2018)
 
Addressing data plane performance measurement on OpenStack clouds using VMTP
Addressing data plane performance measurement on OpenStack clouds using VMTPAddressing data plane performance measurement on OpenStack clouds using VMTP
Addressing data plane performance measurement on OpenStack clouds using VMTP
 
Continuous Kernel Integration
Continuous Kernel IntegrationContinuous Kernel Integration
Continuous Kernel Integration
 
Real time operating systems (rtos) concepts 3
Real time operating systems (rtos) concepts 3Real time operating systems (rtos) concepts 3
Real time operating systems (rtos) concepts 3
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
 
Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"
 
Write code that writes code!
Write code that writes code!Write code that writes code!
Write code that writes code!
 
Apache airflow
Apache airflowApache airflow
Apache airflow
 

En vedette

العمليات الجبرية2
العمليات الجبرية2العمليات الجبرية2
العمليات الجبرية2
ealjelani
 
нуклемновые кислоты
нуклемновые кислотынуклемновые кислоты
нуклемновые кислоты
nadsav
 
Deliberazioni esposte 1
Deliberazioni esposte 1Deliberazioni esposte 1
Deliberazioni esposte 1
barsanofio
 
Latihan4 michael 5133331019
Latihan4 michael 5133331019Latihan4 michael 5133331019
Latihan4 michael 5133331019
Michael Mick
 
գարեգին նժդեհ
գարեգին նժդեհգարեգին նժդեհ
գարեգին նժդեհ
ekoligia
 
Kc common household consumption
Kc common household consumptionKc common household consumption
Kc common household consumption
nicolelopez9
 

En vedette (20)

Research
ResearchResearch
Research
 
Question 3
Question 3Question 3
Question 3
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
العمليات الجبرية2
العمليات الجبرية2العمليات الجبرية2
العمليات الجبرية2
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
нуклемновые кислоты
нуклемновые кислотынуклемновые кислоты
нуклемновые кислоты
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Deliberazioni esposte 1
Deliberazioni esposte 1Deliberazioni esposte 1
Deliberazioni esposte 1
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Bulan+dygo
Bulan+dygoBulan+dygo
Bulan+dygo
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Latihan4 michael 5133331019
Latihan4 michael 5133331019Latihan4 michael 5133331019
Latihan4 michael 5133331019
 
Panopoly - Boulder DBUG 13 Nov 2013
Panopoly - Boulder DBUG 13 Nov 2013Panopoly - Boulder DBUG 13 Nov 2013
Panopoly - Boulder DBUG 13 Nov 2013
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
գարեգին նժդեհ
գարեգին նժդեհգարեգին նժդեհ
գարեգին նժդեհ
 
皮飾配件
皮飾配件皮飾配件
皮飾配件
 
Kc common household consumption
Kc common household consumptionKc common household consumption
Kc common household consumption
 
computer memory
computer memorycomputer memory
computer memory
 

Similaire à Meteor Boulder meetup #1

react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
janet736113
 
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on KubernetesApache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
DataWorks Summit
 
Os7 2
Os7 2Os7 2
Os7 2
issbp
 

Similaire à Meteor Boulder meetup #1 (20)

The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor Framework
 
React state management with Redux and MobX
React state management with Redux and MobXReact state management with Redux and MobX
React state management with Redux and MobX
 
Why meteor
Why meteorWhy meteor
Why meteor
 
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - Intro
 
O365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - MaterialO365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - Material
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-FunctionsIntegration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
 
Server-side JS with NodeJS
Server-side JS with NodeJSServer-side JS with NodeJS
Server-side JS with NodeJS
 
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on KubernetesApache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
Plone FSR
Plone FSRPlone FSR
Plone FSR
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverless
 
Meteor Angular
Meteor AngularMeteor Angular
Meteor Angular
 
Os7 2
Os7 2Os7 2
Os7 2
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Meteor Boulder meetup #1

  • 2. PART I: WHY METEOR?
  • 3. What is Meteor? • Full-stack JavaScript Framework • Build tool • Package system • Real-time protocol - DDP • Built on Node.js • Currently integrates with Mongodb (others to follow)
  • 5. What we saw • Instant dev environment • A working base app • Smart packages • Hot code push • Code can run on client, server, or both • Mongo api can be used locally to access server • Reactive templates • Data kept updated to all connected browsers • Session store local – maintained through hot code pushes • easy deployment to meteor.com • bundle for deployment to any node.js environment
  • 6. So Why Meteor? • Real-time (chat, dashboard, games, etc.) • Rapid prototyping • Productive • Declarative • All JavaScript
  • 7. Further resources • docs.meteor.com and blog.meteor.com • Discover Meteor (book) – highly recommended • Meteor Weekly (newsletter) • Meteor 101 screencast (Naomi Seyfer) • www.eventedmind.com • IRC • Google Groups • Github • win.meteor.com – for Windows users
  • 9. PART II: REACTIVITY How does Meteor achieve live client-side updates?
  • 10. Meteor Advanced Topics • Goal: useful for both beginners and advanced users • A lot of “magic” in Meteor • Is Meteor the jQuery of web app development? Abstraction debt? • Meteor’s hidden parts are in plain view – just go look • Great chance to pick something to research and share with the group
  • 11. What is Reactivity? • Reactivity describes a declarative data flow through which changes propagate automatically. • i.e., Data/variables update automatically when their upstream dependencies change. • Spreadsheet is the typical example
  • 13. Meteor Computations A computation contains a stored function to be rerun whenever required. A function running inside a computation is said to be running in a reactive context. _func: function () { return Session.get(“a1”)+ 1; } .stop() .invalidate() a Deps.Computation:
  • 14. Step 1: Put functions in computations To place any function fn in a computation: Templates and template helpers are automatically put in a computation by Meteor. Code in fn is said to be running in a reactive context. In a reactive context, Deps.active===true handle = Deps.autorun(fn);
  • 16. Reactivity Requirements Meteor Reactivity requires two things: 1. Run your code in a reactive context (e.g., with Deps.autorun()). 2. Use a reactive data source inside the computation. Other data sources will not update reactively.
  • 17. Built-in Reactive Data Sources • Session.get(“key”) • Collection.find({sel}) • Meteor.user() • Meteor.userId() • Meteor.status() • <subscription>.ready() • Meteor.loggingIn() Or use one from an outside module e.g. Iron Router’s Router.current()
  • 18. Making a reactive data source Why? • Control what to reactively respond to • Create a package with reactive API • Better code organization (Session === global?) • To really understand what you are doing
  • 19. Reactive Data Source is In Charge • <data source>.get(): Data source stores the current computation in a list of dependencies. • <data source>.set(): Data source calls the .invalidate() method on each computation in its list. Comp id=1 Comp id=2 Comp id=3 id=1 Id=2 Id=3 Reactive Data Source source.get() Comp id=1 Comp id=2 Comp id=3 id=1 Id=2 Id=3 Reactive Data Source invalidate() Registering dependencies Invalidating dependencies on change
  • 20. Deps.Dependency object To create a reactive data source: • Create a new Deps.Dependency() • Call its .depend() method to register a computation • Call its .changed() method to invalidate all dependencies _dependentsById: .changed() Computation {_id:1} Computation {_id:2} Computation {_id:3} .depend()
  • 21. Demo – make a reactive data source
  • 22. Quiz: Will this update reactively? Session.set('a', 1); var x = Session.get('a') Deps.autorun(function () { console.log(x); //console logs 1 }); Session.set ('a', 2); //console logs ???
  • 23. What we didn’t cover • Cascading dependencies and Deps.flush() • Cleanup and other implementation details. • Other Meteor packages that play a part in full-stack reactivity • Spark/UI • Publish/subscribe • Events • Observe and other callback-based mechanisms • Remember, Deps works on the client only!
  • 24. Resources • robertdickert.com: Why Is My Meteor App Not Updating Reactively? • https://github.com/meteor/meteor/tree/devel/packages/de ps • www.eventedmind.com
  • 26. Other possible surprises • Computations run the whole function • You need to .stop() unneeded computations • Deps does not run on the server • Know the difference between this and other Meteor packages that playa part in “full-stack reactivity” • Spark/UI • Publish/subscribe • Events • Observe and other callback-based mechanisms
  • 27. The data source is in charge 1. Stores computations in Deps.Dependency instance 2. Decides when to register a dependency (dependency.depend()) 3. Triggers the .invalidate() method of every dependent computation (dependency.changed()).
  • 28. • B1 needs to be rerun over and over • It needs to be rerun when A1 changes  B1 is dependent on A1 • B1 is a computation (aka “reactive context”) • A1 is a reactive data source
  • 29. Meteor Features • One language • Database everywhere • Latency compensation • Full stack reactivity • Hot code pushes • Low-friction prototyping and deployment