Skip to content

Instantly share code, notes, and snippets.

@sis0k0
Created May 25, 2017 12:57
Show Gist options
  • Save sis0k0/11ebb610301e305563cb3b805844d722 to your computer and use it in GitHub Desktop.
Save sis0k0/11ebb610301e305563cb3b805844d722 to your computer and use it in GitHub Desktop.
import { NgModule, APP_INITIALIZER } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import {
on as applicationOn,
suspendEvent,
ApplicationEventData,
} from "application";
import { AppComponent } from "./app.component";
import { CountDownTimerService } from "./countdown-timer.service";
export const handleSuspend = (countDownTimerService: CountDownTimerService) =>
() => applicationOn(suspendEvent, (args: ApplicationEventData) => {
if (args.android) {
countDownTimerService.startCountDown(1);
} else if (args.ios) {
console.log("UIApplication: " + args.ios);
}
});
@NgModule({
bootstrap: [ AppComponent ],
imports: [ NativeScriptModule, ],
declarations: [ AppComponent, ],
providers: [
CountDownTimerService,
{
provide: APP_INITIALIZER,
useFactory: handleSuspend,
deps: [CountDownTimerService],
multi: true,
},
],
})
export class AppModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment