Fireship · @fireship
Angular Ngrx Effects with Firebase Database
Uploaded August 30, 2017 · Length 8:57
Summary
Learn how to implement Angular Ngrx Effects with Firebase Database, including setting up the app, creating post effects and reducer, and handling side effects.
- angular ngrx effects
- firebase database
- ngrx store
- angular firebase
- side effects
- angular effects
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
in my last video I showed you how to
- 0:01
implement Redux patterns and angular
- 0:03
using ng rx store if you're brand new to
- 0:06
redux I recommend checking out that
- 0:07
video first if you haven't already if
- 0:09
you're an angular firebase Pro member
- 0:11
I'd like to take a second to say thank
- 0:13
you for supporting this project and let
- 0:15
you know that we're using your
- 0:16
investment to support other open-source
- 0:18
projects such as ng rx I pledged $100
- 0:21
per month and will do the same for other
- 0:23
exceptional angular projects and content
- 0:25
creators getting back to this episode
- 0:27
we're going to build an ng rx angular
- 0:30
app that uses firebase on the backend
- 0:32
we'll be able to retrieve as well as
- 0:34
update post on the firebase real-time
- 0:36
database when working with firebase we
- 0:39
have to worry about the side effects
- 0:40
that come with working with a third
- 0:42
party API ng Rx has a package called
- 0:45
effects that serves just this purpose we
- 0:47
can install it using NPM at this point
- 0:50
you should have angularfire 2 for
- 0:52
firebase installed you can find
- 0:53
instructions for that on the official
- 0:55
repo now let's look at why we need to
- 0:57
use effects in the first place
- 0:58
consider the following example of a pure
- 1:01
function it's considered a pure because
- 1:03
it only affects data within its own
- 1:04
scope it would be considered impure if
- 1:07
we defined a variable
- 1:08
outside of that function and then used
- 1:10
it inside the function scope what often
- 1:12
happens in the real world is we have an
- 1:14
impure function that will do an
- 1:15
operation on the database causing a
- 1:17
chain of different side effects in the
- 1:18
application the goal of ng rx effects is
- 1:21
to isolate functions like this to make
- 1:23
them behave more or less like a pure
- 1:25
function let's start coding this up in
- 1:27
angular in the app module we're going to
- 1:30
need the angular fired database as well
- 1:32
as the effects module store and store
- 1:35
dev tools then we're going to create our
- 1:37
own post effects and post reducer in the
- 1:39
upcoming steps post effects behave just
- 1:42
like an angular service so when we
- 1:44
import them we add them to an array and
- 1:46
the effects module then the reducer is
- 1:48
added to the store module now before
- 1:51
going any further I want to show you how
- 1:52
I have this app organized I have a
- 1:54
folder for actions effects models and
- 1:57
reducers you'll most likely want a
- 1:59
similar organization to this for each


