Files
doneit-web/src/app/services/change-profile.service.ts
T
Peter Maquiran c2243c8029 Fix
2021-09-28 11:31:10 +01:00

43 lines
647 B
TypeScript

import { Injectable } from '@angular/core';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
providedIn: 'root'
})
export class ChangeProfileService {
callbacks: {
funx: Function
id: string
}[] = []
constructor() { }
registerCallback(funx: Function, object: any = {} ) {
const id = uuidv4()
this.callbacks.push({funx, id})
return id;
}
deleteCallback(id) {
this.callbacks.forEach((e, index)=> {
if(e.id == id) {
if (index > -1) {
this.callbacks.splice(index, 1)
}
}
})
}
run() {
this.callbacks.forEach((e, index)=> {
e.funx()
})
}
}