fix: fixing eslint problems
This commit is contained in:
@@ -9,7 +9,7 @@ import { AppComponent } from './app.component';
|
||||
import { MutiplesComponent } from './components/mutiples/mutiples.component';
|
||||
|
||||
// AoT requires an exported function for factories
|
||||
export function HttpLoaderFactory(http: HttpClient) {
|
||||
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
|
||||
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export class MutiplesComponent implements OnInit {
|
||||
input: new FormControl(Math.round(Math.random() * 100) % 10),
|
||||
});
|
||||
|
||||
multiples = [];
|
||||
multiples: number[] = [];
|
||||
|
||||
constructor(
|
||||
private electronIpc: ElectronIpcService,
|
||||
@@ -23,13 +23,16 @@ export class MutiplesComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
// Specifying what to do with received data from main process
|
||||
this.electronIpc.receive(WindowApiConst.MULTIPLES_OUTPUT, (...data: []) => {
|
||||
// Update current data
|
||||
this.multiples = data;
|
||||
});
|
||||
this.electronIpc.receive<number[]>(
|
||||
WindowApiConst.MULTIPLES_OUTPUT,
|
||||
(output: number[]) => {
|
||||
// Update current data
|
||||
this.multiples = output;
|
||||
}
|
||||
);
|
||||
|
||||
// Reset multiples on form changes
|
||||
this.timesTableForm.valueChanges.subscribe((value) => {
|
||||
this.timesTableForm.valueChanges.subscribe(() => {
|
||||
this.multiples = [];
|
||||
});
|
||||
|
||||
@@ -37,12 +40,12 @@ export class MutiplesComponent implements OnInit {
|
||||
this.onSubmit();
|
||||
}
|
||||
|
||||
translateIn(lang: string) {
|
||||
translateIn(lang: string): void {
|
||||
this.translate.use(lang);
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
const intput = this.timesTableForm.value.input;
|
||||
this.electronIpc.send(WindowApiConst.MULTIPLES_INPUT, intput);
|
||||
onSubmit(): void {
|
||||
const input = this.timesTableForm.value.input;
|
||||
this.electronIpc.send(WindowApiConst.MULTIPLES_INPUT, input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,37 +8,33 @@ export class ElectronIpcService {
|
||||
private _api!: WindowApi;
|
||||
|
||||
constructor(private zone: NgZone) {
|
||||
if (window && (window as any).api) {
|
||||
try {
|
||||
this._api = (window as any).api;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
if (window && (window as Window).api) {
|
||||
this._api = (window as Window).api;
|
||||
console.log('Preloader API has been loaded successfully');
|
||||
} else {
|
||||
console.warn('Preloader API is not loaded');
|
||||
}
|
||||
}
|
||||
|
||||
public receive(channel: string, func: (...data: any) => void): void {
|
||||
public receive<Out>(channel: string, func: (output: Out) => void): void {
|
||||
if (this._api) {
|
||||
this._api.receive(channel, (...data) => {
|
||||
console.log(`Received from main process channel [${channel}]`, data);
|
||||
this._api.receive<Out>(channel, (output) => {
|
||||
console.log(`Received from main process channel [${channel}]`, output);
|
||||
|
||||
// Next code might run outside of Angular zone and therefore Angular
|
||||
// doesn't recognize it needs to run change detection
|
||||
// Further details on SO : https://stackoverflow.com/a/49136353/11480016
|
||||
this.zone.run(() => {
|
||||
func(...data);
|
||||
func(output);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public send(channel: string, ...data: any): void {
|
||||
public send<In>(channel: string, input: In): void {
|
||||
if (this._api) {
|
||||
console.log(`Sending to main process channel [${channel}]`, data);
|
||||
this._api.send(channel, ...data);
|
||||
console.log(`Sending to main process channel [${channel}]`, input);
|
||||
this._api.send<In>(channel, input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user