1 of 43

Make your Apps Realtime with Firebase and Vue

2 of 43

Eduardo

Vue.js Core Team

Vue.js Meetup Paris

vue-mdc, vuexfire, vue-motion

Lead Teacher at Ironhack

3 of 43

4 of 43

5 of 43

Dataflow

6 of 43

7 of 43

Multi-user interaction

8 of 43

9 of 43

Multi-user interaction + Big dataset

10 of 43

Realtime usecases

  • Flow of data
  • Instant feedback
  • Multi-user
    • 1 group 1 dataset
    • N groups N datasets

11 of 43

How to realtime?

12 of 43

Short Polling

Is it ready?

Not yet

ready?

no

now?

no, plz stahp

13 of 43

Short polling vs Server

14 of 43

Long Polling

wait

Is it ready?

Now, it is

Thx

15 of 43

Server Sent Events

Hey, you need this

Thx

16 of 43

WebRTC

17 of 43

WebSockets

> 9

18 of 43

19 of 43

Declarative rendering

20 of 43

View

State

Render

User Input

21 of 43

Classic databases

22 of 43

Classic databases

23 of 43

Realtime database

24 of 43

State

View

25 of 43

26 of 43

Firebase is not just a Database

27 of 43

Firebase also has

Authentication

Cloud Functions

Hosting

Storage

Cloud Messaging

...

28 of 43

Data in Firebase

{

"todos": [

"Learn Vue",

"Learn Firebase",

"Build things 🔨"

]

}

29 of 43

Data in Firebase

{

"todos": {

"todo_1": "Learn Vue",

"todo_2": "Learn Firebase",

"todo_3": "Build things 🔨"

}

}

30 of 43

Firebase listeners

var todosRef = db.child('todos')

todosRef.on('child_added', s => ...)

todosRef.on('child_removed', s => ...)

todosRef.on('child_changed', s => ...)

todosRef.on('child_moved', s => ...)

31 of 43

Data driven UI

{

todos: [...]

}

{

todos: {...}

}

32 of 43

Data driven UI

{

cart: [...]

}

todosRef

33 of 43

new Vue({

firebase: {

todos: todosRef

}

})

34 of 43

const setTodosRef = firebaseAction(

({ bindFirebaseRef, state }, { ref }) => {

bindFirebaseRef('todos', ref)

}

)

35 of 43

36 of 43

The bad parts

37 of 43

Unfolding the truth

38 of 43

Limitations

  • Limited queries
  • Messy JOINs
  • Filter by multiple keys → new keys (SO)
  • Pagination (firebase-paginator)

→ Often retrieves the whole collection in client

39 of 43

Don’t use with

  • Heavy relational models
  • Huge datasets + heavy filtering

40 of 43

Easy to start with

Takes time to master

41 of 43

Good points

  • Super approachable
  • Prevents you to write complicated logic
  • More than just a Database

42 of 43

43 of 43

Thanks