Fireship · @fireship
Loading Spinners for Asynchronous Firebase Data
Uploaded May 1, 2017 · Length 2:31
Summary
display and hide loading spinner with firebase data in angular
- firebase loading spinner
- angular async data
- loading indicators
- angular fire
- ui components
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
in this episode I will show you how to
- 0:02
display and hide a loading spinner when
- 0:04
retrieving a synchronous fire-based data
- 0:07
from an angular application loading
- 0:09
indicators are an important user
- 0:11
interface feature because they show the
- 0:13
end user when more data is incoming step
- 0:17
1 create the spinner component we're
- 0:20
going to create a spinner component that
- 0:22
can be reused throughout the application
- 0:24
to make it look cool I'm going to use
- 0:26
the spin kit CSS library which can just
- 0:29
be copied directly into the components
- 0:31
CSS and HTML files at this point you
- 0:34
don't need to change anything in the
- 0:35
components typescript step to retrieve
- 0:43
asynchronous data we need to load some
- 0:46
data from firebase in order to make use
- 0:48
of the spinner in this example I'm
- 0:50
loading a firebase list observable via
- 0:53
the angular fire to package the actual
- 0:56
data is just an array of items from a
- 0:58
to-do list this code is originally
- 1:01
created for the real-time database video
- 1:03
so check out it if you want to learn
- 1:05
more about asynchronous data streams
- 1:06
from firebase step 3 the show and hide
- 1:13
the spinner we want to show the spinner
- 1:16
in the items list component when the
- 1:18
data is being retrieved
- 1:20
first we define a variable called show
- 1:23
spinner in the component and set it to
- 1:26
true by default during the ng on a net
- 1:29
life cycle so the data is requested from
- 1:33
the service as the firebase lists
- 1:35
observable we can determine if the data
- 1:38
has been loaded by subscribing to it the
- 1:41
function inside the subscribed call will
- 1:43
be executed after the observable emits
- 1:45
some data so we can simply set the show
- 1:49
spinner variable to false once this
- 1:50
happens in the template we can use the
- 1:56
ng-if directive with the show spinner
- 1:58
variable to control the visibility of


