-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure to import methods into /imports/startup/client/index.js #53
Comments
This is one to explore further (cc @pilarArr). As you've explained, yes, the methods we've defined are server-side only. I've wanted to avoid validated methods as they add a layer of abstraction that can be difficult to understand for beginners (and adds a ton of "but wait, what is..." type of questions to the mix). I've never investigated as I haven't had any trouble with server-only methods, but can we do a simple |
yes you are right, trying to understand the logic behind validated methods could be hard for beginners, even more if you never created a regular meteor method before. if you want to have client-only or shared methods, you either create the methods.js file under |
Flagging this as a refactor. Ideally, we should do what we do on the server. So,
@tafelito can I get a spot check that I'm understanding this correctly? |
Yes thats correct. Another way of doing it is maybe just create an api.js shared between client/server and another api.js for each server and client for those cases where you need a client-only or server-only methods something like
then you pull both I'm not sure if I like putting the The advantage of this is that you don't have to write the same imports in both |
I found that methods declared in
imports/api/<module>/methods.js
(e.g.: documents) are not being called from the client. This is because they are not being imported anywhere from the client side. They are imported from the server though. So the Optimistic UI feature won't work in that case.One way to solve this is importing methods that are not inside
server
directories withinstartup/client/index.js
or create methods usingmdg:validated-method
and then just importing the method to call from the component itself or wherever you use the method.callBetter explained here meteor/guide#491
The text was updated successfully, but these errors were encountered: