Many of you must have used MeteorJS Methods and have often mistook them for an analogue of REST API. Although Meteor Methods are similar to POST API request but they are quite different.
The main difference between the two is that Meteor Methods are DDP (Distributed Data Protocol) messages and are based on RPC (Remote Procedure Calls) whereas REST API is based on HTTP request.
The benefits of Meteor Methods over REST API are as follows:
- If multiple Methods are called in your app, they return in the same sequence whereas there is nothing as such in REST API.
- If we make another method call inside a method based on its result, only one call will go to the server as the processing is done on the server itself. In case of REST APIs, we need to send another request to the server for the same scenario.
- Whenever a Meteor Method is called, a client side simulation of the method starts and changes the UI as per the predicted result of the method. If the result is as expected, then it does nothing and otherwise, it fires an update callback. The results are predicted using the automatic database tracker. This feature is known as Optimistic UI (the ability to simulate server-side actions on the client to make your app feel faster than it actually is).
The concept of Methods is really interesting but at the same time, MeteorJS removes the distinctions between front end and back end, thus making it less popular.
Leave a Reply Cancel reply