Comment below with a link to your repo and production link.
- Show 'SyncManager' and 'Notification' objects in window
- Request approval for notifications in the browser
- If serviceWorker registration and installation is successful and the serviceWorker is ready, then add an event listener to the submit button to add an article to the sync queue
main.js
if ('serviceWorker' in navigator && 'SyncManager' in window && 'Notification' in window) {
window.addEventListener('load', () => {
fetchLatestHeadlines();
navigator.serviceWorker.register('./service-worker.js')
// Without the `sendMessage()` promise-based function, but we want to teach them how to handle if something goes wrong here? | |
if ('serviceWorker' in navigator && 'SyncManager' in window && 'Notification' in window) { | |
window.addEventListener('load', () => { | |
fetchLatestHeadlines(); | |
navigator.serviceWorker.register('./service-worker.js') | |
.then(registration => navigator.serviceWorker.ready) | |
.then(registration => { | |
Notification.requestPermission(); | |
$('#submit-article').on('click', function(event) { |
Server-side testing is another crucial facet of testing. As your app grows in size and complexity, there will be more points of potential failure. Server-side testing focuses on looking at a request coming from a client, processing the request, and testing if the correct response to the client is given.
Everyone draw a diagram of how you envision your Jet Fuel app working - the entire process of the request and response cycle from the client to the server and back to the client.
Ever wonder how your linter knows if you have matching brackets? Well it's time to think of a solution to that!
Given a set of brackets, [, {, (
, create a function that determines if the brackets are well-formed (match) or not - even with bracket nesting. For example:
bracket('{}');
// => true
For this assignment, you'll be reintroduced to Promises and then write your own!
Asynchronous code is everywhere in JavaScript, and Promises are a tool that enable us to work with asynchronous code in a manageable way. You've probably consumes promises before, most likely when you used the fetch
API, but how are they working under the hood. With fetch, you most likely used something like this for a GET request:
fetch('http://www.some-api/users')