admin管理员组

文章数量:1186686

I've been using backbone recently as my client-side framework. On the server I use Express.js. Still, I was reading about Meteor and realized that it was a rather interesting 'full-stack' framework.

Is the usage of Backbone and Meteor complementary, or with Meteor can one simply ditch Backbone (or any other MV*)?

I've been using backbone recently as my client-side framework. On the server I use Express.js. Still, I was reading about Meteor and realized that it was a rather interesting 'full-stack' framework.

Is the usage of Backbone and Meteor complementary, or with Meteor can one simply ditch Backbone (or any other MV*)?

Share Improve this question edited Dec 15, 2013 at 9:29 JJJ 33.2k20 gold badges94 silver badges103 bronze badges asked Nov 10, 2012 at 15:12 tUrG0ntUrG0n 4,4483 gold badges22 silver badges27 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 27

That's right. The different parts of Meteor like Meteor.Collection (the Mongo database API that also works on the client) and Template (the Handlebars style templates that automatically redraw when data changes) work together. So any time one user makes a change, all the other tabs that are allow access to that data will automatically redraw. If you're using them, then you don't need a separate library like backbone on the client.

Backbone is built for an earlier style of application, where you have separate client and server code written with different APIs. In that model, the server side exposes a REST API and backbone's job is to provide some structure on the client for how to query that API and draw the screen based on the data that comes back. But you still have to write all the data synchronization and model validation code by hand before you have a realtime app, and you have to do it twice: once on the client and once on the server.

There's one exception: many of us do use backbone's router in our Meteor applications. The code below is from the Todo List example.

////////// Tracking selected list in URL //////////

var TodosRouter = Backbone.Router.extend({
  routes: {
    ":list_id": "main"
  },
  main: function (list_id) {
    Session.set("list_id", list_id);
    Session.set("tag_filter", null);
  },
  setList: function (list_id) {
    this.navigate(list_id, true);
  }
});

Router = new TodosRouter;

Meteor.startup(function () {
  Backbone.history.start({pushState: true});
});

There is an existing meteorite smart package called meteor-router. Perhaps it can help you migrate your existing backbone code.

本文标签: javascriptAre meteorjs and backbonejs complementaryStack Overflow