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() { } |
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> |
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) { |
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; | |
} |
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; | |
} |
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 | |
} |
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{ | |
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){ |
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; |
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