Installation
meteor npm i --save meteor-method
Usage
Create a method:
; ;
Use the method you created:
; fooMethod;// OR, in an async/await style: { console;};
This replaces the traditional way of creating and calling Meteor methods:
// Create a methodMeteor; // Use the methodMeteor;
This removes reliance on magic strings and enables type checking if you use TypeScript (see below).
API
Method#call
: returns a Promise for the result of the callback you passed in when you created the method.
Notes for TypeScript:
This module comes with typings. Visual Studio Code supports full type inference:
;;fooMethod.call1; // Error since you are passing a number instead of a date
TypeScript currently doesn't support inference if you have 0 arguments, so this will give you an error:
;;fooMethod.call; // Error because TypeScript still thinks you should pass an argument.
Instead, use the MethodWithoutArgs
class:
;;fooMethod.call; // All good