A Meteor remote procedure call (RPC) invokes a function on the server from the client using DDP.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
methods_collections
methods_crossbar
methods_ddp
methods_intro
methods_localcache
methods_replace_example
methods_syncwrites_diagram
methods_syncwrites_intro
methods_unblock
methods_writefence
README.md

README.md

Class: RPC with Meteor Methods

Meteor


A Meteor remote procedure call (RPC) invokes a function on the server from the client using DDP. You're using RPC every time you insert, update or remove a document from a minimongo collection or making a Meteor method call. We'll take a detailed look at how a document write to a mongo collection gets synchronized between the client and the server. Finally, we'll look at how to improve performance by unblocking method calls.

What's in this class?

  • Introduction to Meteor Methods - In this class we'll cover Meteor's RPC (Remote Procedure Call) implementation, which Meteor calls Meteor Methods. You can call a function on the server from the client using Meteor.call().

  • A Tour of Meteor Methods - Meteor methods is an implementation of remote procedure calls (RPC). It lets a client call a function on the server and get a result over the wire. We'll start off by looking at some code examples of defining and using methods. You'll see how to define and call a method as well as how to compensate for latency by defining a method "stub."

  • The Mechanics of Methods - What actually happens when you make a Meteor method call? In this video we'll explore the DDP messages and mechanics behind a Meteor method call.

  • Collections Use Methods - Meteor Collections actually use Meteor Methods under the hood to send "writes" (insert, update, remove) to the server. In this video we'll look at a few examples.

  • The Invalidation Crossbar - Meteor uses a data structure called the Invalidation Crossbar notify listeners that something has changed. For example, Mongo Livedata uses this structure to let observers know about a write to a document. In this video we'll explore how this data structure works.

  • Using the Write Fence - When you make a Meteor method call, the server sends the "updated" message once all writes on the server have been committed. It does this using a data structure called a Write Fence. In this video we'll explore the Write Fence by using it in our application.

  • Synchronizing Method Writes - Meteor synchronizes writes that happen on the client with the result we ultimately get back from the server. In this video you'll get some intuition about what this means.

  • Mechanics of Method Writes - In this video we'll dive deeper into writing a document in a method by diagraming how Meteor actually synchronizes a write between a client and the server.

  • Writing Our Own Local Cache - In our applications we use Minimongo in the browser as the local data cache. But in this video we'll build our own simple local cache so you can better see how it works with Livedata to keep data in sync between the client and server.

  • Saving and Retrieving Original Documents - We'll complete our implementation of a local cache by adding the saveOriginals and retrieveOriginals methods.

  • Unblocking a Method - Meteor DDP messages are processed sequentially, each in their own Fiber. This means our publish functions and methods are run one after the other and if one of those functions pauses its fibers, the rest of the messages have to wait. We can unblock the message queue by using this.unblock in our methods. In this video I'll show you how messages get processed on the server and what it means to unblock a method.