Fireship · @fireship
Learn @ngrx/entity and Feature Modules
Uploaded October 26, 2017 · Length 9:50
Summary
Learn how to use @ngrx/entity and feature modules in Angular to manage global data and perform CRUD operations.
- ngrx entity
- angular feature modules
- ngrx store
- crud operations
- angular state management
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
the worst thing about ng Rx is the sheer
- 0:02
amount of code that it takes to build
- 0:04
anything but you're rewarded for that
- 0:05
extra effort with a global data store
- 0:07
that's easy to test and debug and cool
- 0:10
things like the Redux dev tools here on
- 0:12
the right to address the amount of
- 0:14
boilerplate code in ng rx they recently
- 0:16
released a new package called entity it
- 0:18
provides a standardized way to manage
- 0:20
collections of objects and perform basic
- 0:22
credence on them in this episode I'm
- 0:25
going to use entity to build this basic
- 0:27
Pizza ordering app here on the left and
- 0:29
I'm also going to show you how to build
- 0:31
feature modules with ng Rx if you're new
- 0:33
to my channel make sure to subscribe and
- 0:35
if you're new to ng Rx check out my
- 0:37
previous QuickStart tutorial which is a
- 0:39
much easier introduction into these
- 0:41
concepts I am starting out with a brand
- 0:44
new angular app called ng rx pizza so
- 0:46
will CD into that directory and then
- 0:48
install store and entity from there I
- 0:52
create a new module called pizza this
- 0:54
will be our feature module then I'm
- 0:56
going to add a single component to it
- 0:57
we'll just call that component pizza
- 0:59
order then we'll open the module up and
- 1:02
import the store module then I'm
- 1:05
importing a reducer that has not yet
- 1:07
been created but we're going to get into
- 1:09
that a little bit later we're going to
- 1:11
add the store module to the import
- 1:12
section and then call for feature with
- 1:15
the name of our reducer and the reducer
- 1:17
itself
- 1:18
this approach is trivial here because we
- 1:20
only have one feature but when you have
- 1:21
multiple features this will help keep
- 1:23
your code much more organized so the
- 1:25
next step is to create a directory
- 1:27
called reducers in the app directory and
- 1:29
then inside that create a file called
- 1:31
index is then we'll import action
- 1:34
reducer map and our pizza reducer and
- 1:37
then we'll export all of our reducers as
- 1:40
a single constant in this example we
- 1:42
only have one but you can imagine how
- 1:43
much more convenient this would be if
- 1:45
you had 10 different reducers to manage
- 1:47
at this point we're ready to jump over
- 1:49
to the app module then import the store
- 1:52
module as well as optionally the dev
- 1:54
tools module and then we're going to
- 1:57
import our pizza module that we just
- 1:59
created as well as the reducers index


