Fireship · @fireship
Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Uploaded June 27, 2017 · Length 5:48
Summary
build follow unfollow feature with firebase and angular 4 similar to twitter
- firebase angular 4
- follow unfollow feature
- angular firebase tutorial
- twitter inspired feature
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
in this episode we're going to build a
- 0:02
follow unfollow feature similar to
- 0:04
Twitter using angular for on the front
- 0:06
end and firebase no sequel on the back
- 0:09
end in order to get started with this
- 0:11
lesson you'll need to have firebase
- 0:13
authentication already wired up in your
- 0:15
angular app if you don't have that done
- 0:17
check out the link in the top right
- 0:19
corner for a lesson completely dedicated
- 0:21
to authentication let's start by
- 0:24
modeling the data in a standard sequel
- 0:27
database you could setup a many-to-many
- 0:28
relationship but since we're dealing
- 0:30
with no sequel we have to do things a
- 0:32
little differently the database needs to
- 0:35
answer two fundamental questions first
- 0:37
is the current user following any other
- 0:40
given user and second what is a user's
- 0:43
follower account the first question can
- 0:46
be answered by saving a user's followers
- 0:48
under their own user ID and the second
- 0:51
question can be answered by doing the
- 0:53
exact opposite saving each followed user
- 0:56
ID under their own user ID let's start
- 1:00
putting this together in a service that
- 1:01
will call the Qualla service first we
- 1:06
import the angularfire to database then
- 1:12
we create a function to get a user's
- 1:14
followers this will be used primarily to
- 1:16
build the follower Cal it simply
- 1:19
requests the database object based on
- 1:22
the user ID that's passed as an argument
- 1:25
next we create a function that will tell
- 1:27
us whether or not user a is following
- 1:29
user being
- 1:31
it gets passed to user IDs its arguments
- 1:34
and will query the database for that
- 1:36
specific key value pair if it returns
- 1:40
true we know that that relationship
- 1:41
exists and if it returns null then we
- 1:44
know that that user is not following the
- 1:46
other user from there we can start
- 1:50
building our follow function which will
- 1:53
update the database with the
- 1:55
relationship when the user decides to
- 1:57
follow another user this will make two


