Meteor Best Practices


#1

Hey guys!

I’m putting together a guide for Meteor Best Practices.

Check it out on https://github.com/avalanche1/Meteor-Best-Practices.
I haven’t put much work in it so far - busy building my proj, as I’m sure we all are :smile:; but I hope eventually we all shall find time to contribute and share knowledge, just like we do on this forum :wink:.

First PRs are essentially welcome!


#2

Added

  • Retrieving data from a 3rd party API or other non-Mongo source

#3

you may be interested in this from the guy who co-wrote Discover Meteor and built atmosphere. His unofficial FAQ which I just stumbled upon today during one of my random tangental sessions.


#4

Thank you. I’m already referencing it in ##Misc section of the Guide.
Essentially we cover different topics.


#5

@avalanche1 Would you be interested in adding in this architecture for passing data between the views and handling business logic? This is a pattern i’ve used while building Blonk and a few other prod. apps since then. It makes the app very easy to test and easier to debug. I haven’t written anything yet but would like to write a blog post very soon.

Basic example:

View triggers event (can also pass payload)

Template.SomePage.events({
  'click .btn-logout'() {
    var id = Meteor.userId();
    AppActions.logoutUser(id);
  }
});

Actions call domains that are interested

AppActions = {
  logoutUser(userId) {
    // you could (should) also determine userId here so view does less
    AppDomain.onLogoutUser();
    ProgressDomain.onLogoutUser(userId);
    BarDomain.onLogoutUser(userId);
  }
};

Domains respond to calls made by action(s)

AppDomain = {
  onLogoutUser(userId) {
    Meteor.logout();
    FlowRouter.go('LoginPage')
  }
};

ProgressDomain = {
  onLogoutUser(userId) {
    // in real life a reactive-dict works better...
    Session.set('progress:user:'+userId, null);
  }
};

Here’s more detailed info if this piques your interest:
Flux inspired architecture for Blaze (would like your design opinions!)


#6

Thanks for the input!
Seems like a really interesting approach.
Feel free to submit a PR, but this needs a proper guide on implementation.


#7

Cool. I agree it needs some more guidance. I’m planning on writing up a proper spec/guide repo as well as an examples folder very soon. @sashko was also interested in this… so many projects so little time :laughing:

I’m also thinking about creating a package with helpers to eliminate boilerplate for actions in case they only pass through data to the domain, such as this:

// shorthand
AppActions = Cosmic.generateActions(
  "incrementCounter",
  "decrementCounter"
);

#8

I think the MDG position on this is going to be to see what people come up with, then at some point have a big project to try to consolidate all of the best parts of everything into the standard pattern/best practice for building Meteor apps.

Honestly, since you guys are building real apps with this stuff you are probably closer to the ground on what works and what doesn’t, so I don’t know if I will be super helpful in the initial research stages.


#9

Is http://meteorpedia.com/ still a thing? Maybe it would be well suited as central place for this kind of information. Or maybe MDG can start a wiki where the community can add information?


#10

Doesn’t seem to be very active.
Unlike this forum.


#11

Meteorpedida has good info on it. Came in very handy for me recently with load balancing


#12

Added

  • Use RoboMongo to easily manage your MongoDB data

#13

Added

  • Choosing application structure

#14

Since an official Meteor Guide has been announced, we should all be contributing to it from now on.