Building a Realtime App with Firebase and Ember M3

with Chris Hewell Garrett

@pzuraq

Let's talk data (with Ember M3!)

Agenda

2

3

What is Firebase?

Demo!

1

What is M3?

What is M3?

What problem does M3 solve?

LinkedIn has a lot of data.

  • Thousands of models
  • Nested fragments within other models led to tens of thousands of different models and fragments collectively
  • Difficult to keep it all in sync

Solution: Generated models!

  • No more issues with keeping things in sync
  • Still shipping tens of thousands of generated models and fragments to the client

M3: Mega Morphic Model

{
  "data": {
    "id": "isbn:9780399178481",
    "type": "book",
    "name": "Reincarnation Blues",
    "author": { "type": "person", "id": "3" },
    "chapters": [{
      "name": "The Wise Man of Orange Blossom Key",
      "characters": [{ "type": "character", "id": "4" }],
      "readerComments": [{
        "name": "Someone or Other",
        "body": "Great read!",
      }]
    }],
  },
}
{
  "data": {
    "id": "isbn:9780399178481",
    "type": "book",
    "name": "Reincarnation Blues",
    "author": <Person:3>,
    "chapters": [{
      "name": "The Wise Man of Orange Blossom Key",
      "characters": [<Character:4>],
      "readerComments": [{
        "name": "Someone or Other",
        "body": "Great read!",
      }]
    }],
  },
}
  • Configured via M3 Schema
  • Can work with any conventional API

10,000s of models -> just 1

The largest major refactor to M3 dropped 64kb (min+gzip) of generated code

Is M3 right for you?

  • Handles complex, nested models naturally and fluidly
  • Works well with strong, conventional APIs
  • Less maintenance required to keep frontend and backend in sync
  • Better performance in apps with many models (100s or 1000s)
  • Frontend no longer has model definitions. Can be difficult to understand data model, code can get out of sync easily.
  • Requires a conventional API. Can't work with APIs that are unusual/one-off/bespoke.
  • Relationships are sync - you have to handle that complexity

Pros

Cons

Is M3 right for you?

Large apps with conventional APIs that have a massive number of models and that will benefit from decreased maintenance and payload size.

Small-to-medium sized apps that won't benefit as much from decreased size, and may have more trouble working with dynamic models.

Great for...

Not as great for...

What is Firebase?

Firebase is a backend-as-a-service

Firestore: Document-oriented Database

Firestore Pros and Cons

  • Can represent complex data models pretty easily, no need for 10 tables and 20 joins for something that is conceptually simple
  • Can think about your database and your app in a similar way, makes application development more fluid
  • Limited query capabilities - hard to query arbitrary objects in general
  • No concept of relationships. Relationships have to be managed manually.

Pros

Cons

{
  "data": {
    "id": "isbn:9780399178481",
    "type": "book",
    "name": "Reincarnation Blues",
    "author": { "type": "person", "id": "3" },
    "chapters": [{
      "name": "The Wise Man of Orange Blossom Key",
      "characters": [{ "type": "character", "id": "4" }],
      "readerComments": [{
        "name": "Someone or Other",
        "body": "Great read!",
      }]
    }],
  },
}
{
  "data": {
    "id": "isbn:9780399178481",
    "type": "book",
    "name": "Reincarnation Blues",
    "author": <Person:3>,
    "chapters": [{
      "name": "The Wise Man of Orange Blossom Key",
      "characters": [<Character:4>],
      "readerComments": [{
        "name": "Someone or Other",
        "body": "Great read!",
      }]
    }],
  },
}

M3 + Firestore = Advantages of a document-store, with conventional relationships 

Demo time!

Thank you!

Buliding a Realtime App with Firebase and Ember M3

By pzuraq

Buliding a Realtime App with Firebase and Ember M3

Ember Data is a powerful data layer, but it has its limitations and pain points, especially as applications grow in scale. Ember M3 builds on Ember Data's core, but replaces the default model class with an alternative that is more flexible and lightweight. In this talk, we'll explore M3's capabilities, and then test them out by building an app with M3 and Firestore, a realtime NoSQL database-as-a-service. As we'll see, M3 and Firestore make a perfect pair, enabling rapid prototyping and flexibility, while setting you up for success as your application grows.

  • 763