Exploring Service Workers

Following Along

Kyle Simpson

Kyle Simpson

You Don't Know JS
Exploring Service Workers

Check out a free preview of the full Exploring Service Workers course

The "Following Along" Lesson is part of the full, Exploring Service Workers course featured in this preview video. Here's what you'd learn in this lesson:

Kyle outlines an optional process for following along with the course using commit hashes.

Preview
Close

Transcript from the "Following Along" Lesson

[00:00:00]
>> Kyle Simpson: Your Solution folder will actually have the full solution in it, so the end solution that we get to at the end of this workshop. But in addition, I've included the Git Repo that I used with each of the snapshots that we're getting to. So if you're familiar with Git, you'll note that in the SW Solution folder, you'll see that there's a set of git commits here.

[00:00:28]
So initial commits where we started, and then we added the offline events icon. And then we added our service workers. So this commit is the one that we just got to. And then we're going to do this one next. So, if you, for some reason your stuff is not working and you want to mess around with the git history here, you can check out one of these commits.

[00:00:52]
And if you check out a commit and then wanna get back, you just say git checkout master. So, say that you are having a problem with your code and you wanted to get the solution file code that was correct, you can take that hash, and then add a command line, you can say git checkout and use that hash.

[00:01:12]
And then you'll be at the version of this code now that's in the web directory and all that. The version of this code is that code at that point. And if you do a git log, you'll see that now that one's the top commit, is the one where we added the service worker, okay?

[00:01:32]
So if you wanted then to compare your files to the solution or literally just copy that current state of that over into your exercise folder as a starting point because it's not working, you can do that, okay? If you are on a non, not the final commit, you're in this detached head state.

[00:01:51]
And you wanna get back to the whole list of all the commits because you'll need to do that to go forward. You just say get checkout master. And now you're back to the whole history of the Repo. So then, to go to the next one after the adding service worker, this is what we're about to do, then you'll just grab that hash and you can check that out to that solution.

[00:02:13]
Again, remember you do git checkout as the command you're going to be using. And you either use a hash to go to that specific version of it, or if you've already done that, to get back to what you had before, you do get check out master.
>> Kyle Simpson: Just a word of caution that it's really easy to forget what state a tree is in when you're messing around with this stuff, so pay very close attention.

[00:02:35]
I've checked it out, I'm back to master. I've checked another one out, I'm back to master. When you're copying files or leaving files open in your editor or whatever, it can get real confusing real quick. So just pay close attention to what version of what files you're looking at in this directory.

[00:02:51]
It's also useful for those of you that know about git stuff. I'll show you this. For those of you that know about git stuff. It's useful if, for some reason you wanna know and this is literally what I'm doing to make sure I'm not forgetting code here, to do git diffs between two commits.

[00:03:11]
So here I'm literally looking up right before I walk you through this exercise. I'm looking up the difference between are our adding service worker commit and the status updates, which is what we're about to do. I just do those two hashes from the older to the newer. That's the order, and then, oops.

[00:03:30]
>> Speaker 2: You just have one extra character on the second?
>> Speaker 3: It's not 354, it's-
>> Kyle Simpson: Okay, so now I literally can just see what I'm needing to update and your git diff. So that might be helpful as your managing your stuff.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now