PWA: Service Worker

An important piece of installing a service worker in your application is the ability to update it. Here a brief example of registering the service worker and then instructing it to check for an updated version.


if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
// Check for updates
registration.update();
console.log('SW registered and update called: ', registration);
}).catch(registrationError => {
console.log(registrationError);
});
});
}

Docs:
Service Worker Lifecycles – Manual Updates

Syncing Forks Without Merge Commits II: CLI


# Add an upstream remote for the repo that you just forked from
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

# Fetch the branch info
git fetch upstream

# Check out the local branch you'd like to sync up
# Set it to track against the local master so we can push/pull with shorthand
git checkout master --set-upstream=origin/master

# merge in the changes from the upstream repo
# at this point you should fast-forward and be in sync with the remote branch
git merge upstream/master

# push the local sync up to your repo
# since we set this to track origin/master already there is no need to specify
git push

Docs:
Configuring A Remote For A Fork
Syncing A Fork

Angular: Environment Variables

Add your variable and make sure that you configure each environment.


// ./public_html/src/environments/environment.ts or environment.prod.ts
export const environment = {
production: false,
apiUrl: 'https://example.apiurl.dev'
};

Then import the environment variables and use where necessary.


// ./public_html/src/app/example.ts
import {environment} from '../environments/environment';

export class Example {
public envOptions = {
apiUrl : environment.apiUrl
// ...
}
// ...
}