Skip to content

Commit

Permalink
add generic type for BeforeInstallPrompt token
Browse files Browse the repository at this point in the history
  • Loading branch information
alQlagin committed Jan 28, 2020
1 parent 4a5fc28 commit b513b58
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions projects/ngx-pwa-install/src/lib/ngx-pwa-install.providers.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { InjectionToken } from '@angular/core';
import { fromEvent, ReplaySubject } from 'rxjs';
import { tap } from 'rxjs/operators';
import { BeforeInstallPromptEvent } from './before-install-prompt.event';

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

0 comments on commit b513b58

Please sign in to comment.