Avoid repeating code

hi I’m new to Ionic & Angular. I’m asking you advice about a code simple I used in 5 pages of my app:

HTML CODE:

 <ion-refresher (ionRefresh)="doRefresh($event)">
    <ion-refresher-content pullingIcon="refresh-circle"></ion-refresher-content>
 </ion-refresher>

TYPESCRIPT CODE:

doRefresh(refresher) {
console.log(‘Begin async operation’, refresher);

setTimeout(() => {
  
  console.log('Async operation has ended');
  refresher.complete();
  let toast = this.toastCtrl.create({
  message: "Succes"
  +"\n "+ new Date().toLocaleString(),
  duration: 3000
});
toast.present();
}, 2000);

}

Is there a way to avoid repeating this code in every page?

I found a solution, I used inheritance.