feat: git hook config (husky eslint prettier)
This commit is contained in:
@@ -10,26 +10,26 @@ import { MutiplesComponent } from './components/mutiples/mutiples.component';
|
||||
|
||||
// AoT requires an exported function for factories
|
||||
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
|
||||
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
||||
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent, MutiplesComponent],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
HttpClientModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule.forRoot({
|
||||
defaultLanguage: 'en',
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient],
|
||||
},
|
||||
}),
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent],
|
||||
declarations: [AppComponent, MutiplesComponent],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
HttpClientModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule.forRoot({
|
||||
defaultLanguage: 'en',
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient],
|
||||
},
|
||||
}),
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
@@ -5,47 +5,47 @@ import { WindowApiConst } from 'shared-lib';
|
||||
import { ElectronIpcService } from '../../services/electron-ipc.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-mutiples',
|
||||
templateUrl: './mutiples.component.html',
|
||||
styleUrls: ['./mutiples.component.scss'],
|
||||
selector: 'app-mutiples',
|
||||
templateUrl: './mutiples.component.html',
|
||||
styleUrls: ['./mutiples.component.scss'],
|
||||
})
|
||||
export class MutiplesComponent implements OnInit {
|
||||
timesTableForm = new FormGroup({
|
||||
input: new FormControl(Math.round(Math.random() * 100) % 10),
|
||||
});
|
||||
timesTableForm = new FormGroup({
|
||||
input: new FormControl(Math.round(Math.random() * 100) % 10),
|
||||
});
|
||||
|
||||
multiples: number[] = [];
|
||||
multiples: number[] = [];
|
||||
|
||||
constructor(
|
||||
private electronIpc: ElectronIpcService,
|
||||
private translate: TranslateService
|
||||
) {}
|
||||
constructor(
|
||||
private electronIpc: ElectronIpcService,
|
||||
private translate: TranslateService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
// Specifying what to do with received data from main process
|
||||
this.electronIpc.receive<number[]>(
|
||||
WindowApiConst.MULTIPLES_OUTPUT,
|
||||
(output: number[]) => {
|
||||
// Update current data
|
||||
this.multiples = output;
|
||||
}
|
||||
);
|
||||
ngOnInit(): void {
|
||||
// Specifying what to do with received data from main process
|
||||
this.electronIpc.receive<number[]>(
|
||||
WindowApiConst.MULTIPLES_OUTPUT,
|
||||
(output: number[]) => {
|
||||
// Update current data
|
||||
this.multiples = output;
|
||||
}
|
||||
);
|
||||
|
||||
// Reset multiples on form changes
|
||||
this.timesTableForm.valueChanges.subscribe(() => {
|
||||
this.multiples = [];
|
||||
});
|
||||
// Reset multiples on form changes
|
||||
this.timesTableForm.valueChanges.subscribe(() => {
|
||||
this.multiples = [];
|
||||
});
|
||||
|
||||
// Init time tables with given random value
|
||||
this.onSubmit();
|
||||
}
|
||||
// Init time tables with given random value
|
||||
this.onSubmit();
|
||||
}
|
||||
|
||||
translateIn(lang: string): void {
|
||||
this.translate.use(lang);
|
||||
}
|
||||
translateIn(lang: string): void {
|
||||
this.translate.use(lang);
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
const input = this.timesTableForm.value.input;
|
||||
this.electronIpc.send(WindowApiConst.MULTIPLES_INPUT, input);
|
||||
}
|
||||
onSubmit(): void {
|
||||
const input = this.timesTableForm.value.input;
|
||||
this.electronIpc.send(WindowApiConst.MULTIPLES_INPUT, input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,39 +2,39 @@ import { Injectable, NgZone } from '@angular/core';
|
||||
import { WindowApi } from 'shared-lib';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ElectronIpcService {
|
||||
private _api!: WindowApi;
|
||||
private _api!: WindowApi;
|
||||
|
||||
constructor(private zone: NgZone) {
|
||||
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');
|
||||
}
|
||||
}
|
||||
constructor(private zone: NgZone) {
|
||||
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<Out>(channel: string, func: (output: Out) => void): void {
|
||||
if (this._api) {
|
||||
this._api.receive<Out>(channel, (output) => {
|
||||
console.log(`Received from main process channel [${channel}]`, output);
|
||||
public receive<Out>(channel: string, func: (output: Out) => void): void {
|
||||
if (this._api) {
|
||||
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(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(output);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public send<In>(channel: string, input: In): void {
|
||||
if (this._api) {
|
||||
console.log(`Sending to main process channel [${channel}]`, input);
|
||||
this._api.send<In>(channel, input);
|
||||
}
|
||||
}
|
||||
public send<In>(channel: string, input: In): void {
|
||||
if (this._api) {
|
||||
console.log(`Sending to main process channel [${channel}]`, input);
|
||||
this._api.send<In>(channel, input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user