Refactoring made on offline

This commit is contained in:
Eudes Inácio
2021-10-18 17:42:25 +01:00
parent a9eee0f9a0
commit a21a196248
20 changed files with 1377 additions and 1322 deletions
+24
View File
@@ -5,6 +5,12 @@ import { Injectable } from '@angular/core';
})
export class BackgroundService {
callBacks: {
type: 'Offline' | 'Online',
object?: string
funx: Function
}[] = []
constructor() { }
online() {
@@ -13,6 +19,11 @@ export class BackgroundService {
document.body.style.setProperty(`--color3`, "#0782C9");
document.body.style.setProperty(`--color4`, "#0782c9f0");
document.body.style.setProperty(`--color5`, "#45BAFF");
this.callBacks.forEach((e) => {
if (e.type == 'Online') {
e.funx()
}
})
}
offline() {
@@ -21,5 +32,18 @@ export class BackgroundService {
document.body.style.setProperty(`--color3`, "#ffb703");
document.body.style.setProperty(`--color4`, "#ffb703");
document.body.style.setProperty(`--color5`, "#ffb703");
this.callBacks.forEach((e) => {
if (e.type == 'Offline') {
e.funx()
}
})
}
registerBackService(type: 'Offline' | 'Online', funx: Function, object = '') {
this.callBacks.push({
type,
funx,
object
})
}
}