Fireship · @fireship
NgRx + Firestore
Uploaded November 17, 2017 · Length 10:20
Summary
Learn how to use NgRx with Firestore as a persistent back-end data source in Angular applications.
- ngrx firestore
- angular firestore
- angular ngrx
- firebase firestore
- angularfire2
- ngrx entity adapter
- ngrx effects
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
a few weeks ago I showed you how to use
- 0:01
ng rx entity adapt Paris today I'm going
- 0:04
to build on this concept and show you
- 0:06
how to use fire store as a persistent
- 0:08
back-end data source you might be aware
- 0:10
that angular fire version 5 has a new
- 0:12
state changes method which we're going
- 0:14
to take advantage of in this episode it
- 0:16
makes it possible to keep track of when
- 0:17
documents are added modified or removed
- 0:20
if you want an example of how this might
- 0:22
be used look no further than the
- 0:23
firebase console itself if we add a new
- 0:25
value to the database you'll see it
- 0:27
flashes green first one second and the
- 0:29
document itself is modified so it
- 0:30
flashes orange if we remove the property
- 0:33
then it flashes red the fire store web
- 0:36
console happens to be built with ng rx
- 0:38
which I learned by watching angular air
- 0:39
episode 135 so make sure to check that
- 0:42
out as well if you're new here click the
- 0:44
subscribe button and follow along with
- 0:45
the source code at angular firebase comm
- 0:48
to get started I'm going to first show
- 0:51
you how we have this app setup based on
- 0:52
the previous video starting with the app
- 0:55
module the main change we made is we
- 0:57
installed angularfire 2 along with
- 0:59
firestorm I'm also including the ng RX
- 1:02
effects module and in the root just
- 1:04
passing it an empty array if you're lost
- 1:07
at this point make sure to go back and
- 1:08
watch the ng RX entity video from there
- 1:11
I'm going to go into our pizza feature
- 1:14
module and I have a new file called
- 1:16
pizza effects that we're going to create
- 1:18
later we also import the effects module
- 1:20
here but call for feature and pass it
- 1:22
the pizza effects file the actual app
- 1:25
we're building is just a collection of
- 1:27
pizzas and the user has the ability to
- 1:29
asynchronously update them from a status
- 1:31
of cooking to delivered the thing that's
- 1:34
interesting is that this app is going to
- 1:36
listen for the state changes coming from
- 1:38
angularfire 2 and then use entity
- 1:40
adapters to update the local data store
- 1:43
currently I've queried all the pizzas
- 1:45
that have a status of cooking so if the
- 1:47
status changes from anything other than
- 1:49
cooking it should be removed from our
- 1:50
local data store if we update the status
- 1:53
from cooking to delivered you'll see
- 1:54
that it gets removed from the local data
- 1:56
store and that action is triggered here
- 1:58
and redux dev tools the key takeaway


