View web-socket.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { WebSocketSubject } from 'rxjs/webSocket'; | |
@Injectable() | |
export class WebSocketService { | |
private _ws: WebSocketSubject<string>; | |
constructor() { } |
View app.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebSocket client! | |
<button (click)="sendMessage()">Click me to send message!</button> |
View app.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { WebSocketService } from './services/web-socket.service'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
constructor(private _ws: WebSocketService) { |
View executioner.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Executioner{ | |
execute(data): void; | |
} |
View base-message.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MessageTypeEnum } from "./message-type.enum"; | |
export interface BaseMessage<T> { | |
type: MessageTypeEnum; | |
data: T; | |
} |
View message-type.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export enum MessageTypeEnum { | |
ConsoleLog, | |
ConsoleError, | |
ConsoleTable | |
} |
View error.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Executioner } from '../model/executioner'; | |
import { ErrorUpdate } from '../model/error-update'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class ErrorService implements Executioner{ | |
View service-resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injector } from "@angular/core"; | |
import { MessageTypeEnum } from "../model/message-type.enum"; | |
import { LogService } from "../services/log.service"; | |
import { ErrorService } from "../services/error.service"; | |
import { TableService } from "../services/table.service"; | |
import { Executioner } from "../model/executioner"; | |
export class ServiceResolver { | |
static getService(message: MessageTypeEnum, injector: Injector): Executioner { | |
switch(message){ |
View registry.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, Injector } from '@angular/core'; | |
import { Executioner } from '../model/executioner'; | |
import { ServiceLocator } from '../services/service-locator'; | |
import { MessageTypeEnum } from '../model/message-type.enum'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class RegistryService { | |
private static INSTANCE: RegistryService | undefined = null; |
View service-locator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injector } from "@angular/core"; | |
export class ServiceLocator { | |
static injector: Injector; | |
} |
OlderNewer