Reputation: 4026
Related: Where to include Client-side Startup Code in Meteor React App
Similar issue here.
I want to do some imports from the server and also some initalization once on the client (the sooner the better).
Right now i have my code included in a template:
import { foo } from "../../imports/api/foo/foo.js";
Template.header.events({
//init foo - should be called once and moved elsewehre
...
//use foo
});
But yeah ofc it's stupid because everytime the event is triggered the code gets called again.
On serverside i just used Meteor.startup
for these things.
My Folder structure looks like this:
/config
/models
/packages
/client/components //current code is here
/client/config
/client/lib
/imports/api
/imports/ui
/server/lib
/server/publications
i heard that in previous meteor versions there were some folders for isomorphic code like a /lib
folder but it seems like in meteor (1.3.5) the server and client code is split.
So where is a good place to do some initializations on the client side?
Upvotes: 0
Views: 311
Reputation: 10086
Actually, it doesn't matter where do you place your startup code as long as you're calling it from your client/main.js
.
I'd recommend to follow Meteor
's guide and proposed folder structure: Example directory layout, Structuring imports and Startup files
Upvotes: 2