Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:51:19+00:00 2026-06-13T21:51:19+00:00

Using Meteor, I’m attempting to understand when to use server-side Meteor.methods() while still retaining

  • 0

Using Meteor, I’m attempting to understand when to use server-side Meteor.methods() while still retaining instant UI updates.

From Andrew Scala’s introductory tutorial, he claims that Meteor.methods() should be used when you want to update and modify your database documents:

The idea is that you define all the functions on the server that do
dangerous stuff like modify and update data, and then let the client
call those functions and get return values like regular functions. The
client never sees the implementation and doesn’t personally modify the
data. The server does all the work.

And following this advice, I implemented this in my code:

Server-side:

Meteor.methods({

  addMovie: function(data) {
    var movie = Movies.insert({name: data});
    return movie;
  },

  ...

Client-side:

Template.movies.events = ({

  'click #add-movie': function(e) {

    var name = document.getElementById('movie-name').value;
    Meteor.call('addMovie', name);

    return false;

  }, 

  ...

This works, but it’s slow. The UI doesn’t update instantly like it would if you called Movies.insert() on the client-side. The docs indicate that, to rectify the problem, you can create stubs on the client-side:

Calling methods on the client defines stub functions associated with
server methods of the same name. You don’t have to define a stub for
your method if you don’t want to. In that case, method calls are just
like remote procedure calls in other systems, and you’ll have to wait
for the results from the server.

But what should these stubs look like? Should it basically look the same as the server-side method? If so, what’s the point? I’m looking for a more comprehensive explanation of the use and purpose of Meteor.methods(), the point/use of stubs, and their implementation.

EDIT:
David Greenspan has helped clarify the use of Meteor.methods() and stubs on meteor-talk.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:51:20+00:00Added an answer on June 13, 2026 at 9:51 pm

    here’s another example.

    say you’re writing a bingo game and you click the button to call “house!”.. in the click event you might call a Method, e.g.

    Method.call("callHouse");
    

    this will invoke the server method:

    // on the server
    Meteor.methods({
      callHouse: function () {
        if (currentGame.isInProgress) {
          currentGame.winner = this.userId;
          currentGame.end();
        }
      }
    });
    

    if you are the first to call “house”, the method will mark you as the winner.. however, let’s pretend the method is extremely slow and your client app is waiting.. you’re 99% sure the server will confirm you are the winner – you just want to update the user’s screen without the wait.. in this case implement a client-side stub:

    // on the client
    Meteor.methods({
      callHouse: function () {
        currentGame.winner = Meteor.userId();
        // add any other side-effects you expect to occur here
      }
    });
    

    when the server result returns, if the data returned is different to what you set in the stub, it will correct it and refresh the screen accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using meteor. I'm wondering if theres a shorthand way to do batch updates
Using Meteor, I'm wondering how best to handle different client-side collections that share the
Further to my previous post about obtaining data from objects on the server using
I'm using meteor with the bootstrap package. (here is a chunk of code where
Using SQL Server 2008 R2 we are looking for a way to select the
I'm using following code to parse rather large xml file (> 50GB): use XML::Parser;
I'm attempting to create a class with many parameters, using a Builder pattern rather
I am using Meteor 4.2 (Windows) and I am always getting the update failed:
I tried replicating the todos application without using the example meteor terminal commentlets Steps,
How would I use a (live running) MongoDB to develop another meteor app? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.