@rebase-team/back-button-hook
v0.1.4
Published
<h1 align="center">Back Button Hook</h1> <p align="center">This library was designed to call registered hook functions when the back button was pressed by user..</p>
Downloads
6
Readme
You will need (>= Angular 9) to use this library and an Ionic project (>= v3).
Installation
npm install @rebase-team/back-button-hook
Usage examples
> APP.MODULE.TS
import { AppComponent } from "./app.component";
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BackButtonHookService } from "@rebase-team/back-button-hook";
import { IonicModule } from "@ionic/angular";
@NgModule({
declarations: [],
imports: [
BrowserModule,
IonicModule.forRoot()
],
providers: [
BackButtonHookService
],
bootstrap: [AppComponent],
exports: []
})
export class AppModule { }
> APP.COMPONENT.TS
import { Platform } from '@ionic/angular';
import { Component } from '@angular/core';
import { BackButtonHookService } from "@rebase-team/back-button-hook";
@Component({
selector: "app-root",
templateUrl: "app.component.html",
styleUrls: ["app.component.scss"],
})
export class AppComponent {
constructor(
private platform: Platform,
private backButton: BackButtonHookService
) {
this.backButtonRegister();
}
private backButtonRegister(): void {
this.backButton.Hook.CreateCallback(async () => {
let url = this.platform.url().toUpperCase();
console.log('Back Button triggered on route: ' + url);
});
this.backButton.Hook.Hook();
}
}
Metadata
Muryllo Pimenta de Oliveira – [email protected]
Distribuído sobre a licença MIT. Veja LICENSE
para mais informações.
Contributing
- Fork it (https://github.com/MurylloEx/Back-Button-Hook/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request