You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Meteor method that calls a server function. Angular2, typescript. The method is called from the client. The logic is to insert an uploaded text file into a collection, then call a server method to process things. I do an asynchronous insert, and the Meteor.call in the callback. It works up till there, the document exists in the collection, but the method isn't called on the server.
For collections to work the ts files exporting the collection instance needs to be imported by both the server/main.ts, as well as client/app.ts. It seems that Meteor methods are the same. If the Meteor.method definition is in server/... the call doesn't work. But if I move it to collections/methods, import the files into main and app.ts, the calls to functions defined under server/ cause compiler errors.I think it is the client side compile which can't see the server/ functions.
So what is the suggested strategy? Would wrapping the import {} from calls in isServer as well as the calls themselves work? Is there a compile time flag? Or chaining Meteor method calls?
In th parties example Email is called which is in the Meteor namespace hence doesn't need to be injected. I think that is why.
Thanks.
The text was updated successfully, but these errors were encountered:
The strategy is to split a method into two parts: common and server ones.
Then define two methods: one simplified for the client and one full for the server;
after that import them accordingly where they belong in.
This is the only way to make it with SystemJS since direct System.import is async anyways, with CommonJS though you can import conditionally using require(...).
I have a Meteor method that calls a server function. Angular2, typescript. The method is called from the client. The logic is to insert an uploaded text file into a collection, then call a server method to process things. I do an asynchronous insert, and the Meteor.call in the callback. It works up till there, the document exists in the collection, but the method isn't called on the server.
For collections to work the ts files exporting the collection instance needs to be imported by both the server/main.ts, as well as client/app.ts. It seems that Meteor methods are the same. If the Meteor.method definition is in server/... the call doesn't work. But if I move it to collections/methods, import the files into main and app.ts, the calls to functions defined under server/ cause compiler errors.I think it is the client side compile which can't see the server/ functions.
So what is the suggested strategy? Would wrapping the import {} from calls in isServer as well as the calls themselves work? Is there a compile time flag? Or chaining Meteor method calls?
In th parties example Email is called which is in the Meteor namespace hence doesn't need to be injected. I think that is why.
Thanks.
The text was updated successfully, but these errors were encountered: