Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are meteor.js and backbone.js complementary?

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*)?

like image 1000
tUrG0n Avatar asked Nov 10 '12 15:11

tUrG0n


People also ask

What is backbone JS comparable to?

Vue. js, React, AngularJS, Angular 2, and Ember. js are the most popular alternatives and competitors to Backbone. js.

Is Meteor JS frontend or backend?

It is a Full Stack Framework js to create both the backend and frontend user interface of the application rapidly.

Is Meteor JS still relevant?

Meteor is a popular JavaScript web framework that did have a brief slowdown because of some changes inside the company. The framework is back in the game after some slowdown and can be seen having a bright future ahead of it.

Is Meteor a backend framework?

However, instead of "meteor run" you will be building (meteor build) – your backend into a standard nodeJS app, and your mobile into a signed APK or IOS app. There have been rumors over the years that Meteor doesn't scale well.


2 Answers

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});
});
like image 86
debergalis Avatar answered Oct 14 '22 11:10

debergalis


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

like image 30
Matthew Chen Avatar answered Oct 14 '22 09:10

Matthew Chen