Skip to content

Commit

Permalink
add module providers
Browse files Browse the repository at this point in the history
  • Loading branch information
alQlagin committed Jan 28, 2020
1 parent f3a0359 commit 6df62db
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions projects/ngx-pwa-install/src/lib/ngx-pwa-install.providers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { InjectionToken } from '@angular/core';
import { fromEvent, ReplaySubject } from 'rxjs';
import { tap } from 'rxjs/operators';

export const beforeInstallPromptFactory = () => {
const event$ = fromEvent<Event>(window, 'beforeinstallprompt')
.pipe(
tap(e => e.preventDefault()),
);
const beforeInstallPromptSubject = new ReplaySubject<Event>();
event$.subscribe(beforeInstallPromptSubject);
return beforeInstallPromptSubject;
};
export const BeforeInstallPrompt = new InjectionToken<ReplaySubject<Event>>('BeforeInstallPrompt', {
providedIn: 'root',
factory: beforeInstallPromptFactory
});

0 comments on commit 6df62db

Please sign in to comment.