Skip to content

Angular directive for updating app via service workers

License

Notifications You must be signed in to change notification settings

Celtian/ngx-update-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NgxAppVersion

npm version Package License NPM Downloads Snyk stars forks HitCount

Angular directive for updating app via service workers

Angular 18 compatible

Here's the demo

  • Lightweight
  • No dependencies!
  • Directive way
  • Customizable options...

🛠️ Install

yarn add ngx-update-app

🚀 Quick start

  1. Provide config
import { provideUpdateApp } from 'ngx-update-app';

export const appConfig: ApplicationConfig = {
  providers: [
    provideUpdateApp({
      interval: 1000 * 60, // check new version every minute
      dryRun: false, // set to true if zou want to see alert on init
      onUpdateFactory: () => {
        // you can use inject() here
        return () => alert('Should update');
      }
    }),
    provideServiceWorker('ngsw-worker.js', {
      enabled: !isDevMode(),
      registrationStrategy: 'registerWhenStable:30000'
    })
  ]
};
  1. Use directive in root component
import { NgxUpdateAppDirective } from 'ngx-update-app';

@Component({
  standalone: true,
  hostDirectives: [NgxUpdateAppDirective]
})
export class AppComponent {}

🛠️ Options

Option Type Default Description
interval number undefined interval to check new version in milliseconds
dryRun boolean false force update action once on init
onUpdateFactory function undefined function which will be called on update

🔧 Compatibility

Angular ngx-fixed-footer Install
>= 18 1.x yarn add ngx-update-app
>= 17 0.x yarn add ngx-update-app@0

📦 Dependencies

None

🪪 License

Copyright © 2023 - 2024 Dominik Hladik

All contents are licensed under the MIT license.

About

Angular directive for updating app via service workers

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages