Livsey.org

Musings on Technology & Startup Life

Introducing Fireplace

I’ve been using Firebase with Ember.js quite a lot recently and have just released Fireplace, a library to integrate the two more easily. It’s been extracted from a rather large application so is driven from real world usage.

There’s EmberFire but, aside from it not existing when I started to write Fireplace, it doesn’t support relationships or many other basic / advanced features I’d want in an Ember persistence library.

Anyone who’s used Ember Model or Ember Data should feel at home with Fireplace as I’ve taken inspiration (and code) from many parts of them when developing it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var attr    = FP.attr,
    hasMany = FP.hasMany;

App.Person = FP.Model.extend({
  firstName:   attr(),
  lastName:    attr(),
  dateOfBirth: attr("date"),
  isAdmin:     attr("boolean", {default: false}),
  addresses:   hasMany()
});

App.Address = FP.Model.extend({
  street:   attr(),
  city:     attr(),
  postcode: attr()
});

Fireplace has full support for promises, so fits in nicely with Ember’s router:

1
2
3
4
5
6
7
8
9
10
11
App.PeopleIndexRoute = Ember.Route.extend({
  model: function() {
    return this.store.fetch("person", {limit: 10});
  }
});

App.PeopleShowRoute = Ember.Route.extend({
  model: function(params) {
    return this.store.fetch("person", params.person_id);
  }
})

Check out the project on Github for more details.

Feedback & pull requests are very welcome!

Comments