Files
doneit-web/src/app/services/change-profile.service.ts
T

64 lines
952 B
TypeScript
Raw Normal View History

2021-09-28 11:31:10 +01:00
import { Injectable } from '@angular/core';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
providedIn: 'root'
})
export class ChangeProfileService {
callbacks: {
funx: Function
id: string
}[] = []
2022-12-19 18:38:53 +01:00
callbacksLogin: {
funx: Function
id: string
}[] = []
2021-09-28 11:31:10 +01:00
constructor() { }
registerCallback(funx: Function, object: any = {} ) {
const id = uuidv4()
this.callbacks.push({funx, id})
return id;
}
2022-12-19 18:38:53 +01:00
registerLoginCallback(funx: Function, object: any = {} ) {
const id = uuidv4()
this.callbacksLogin.push({funx, id})
return id;
}
2021-09-28 11:31:10 +01:00
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()
})
}
2022-12-19 18:38:53 +01:00
runLogin() {
this.callbacksLogin.forEach((e, index)=> {
e.funx()
})
}
2021-09-28 11:31:10 +01:00
}