Rename anchor -> key globally ¯\_(ツ)_/¯

This commit is contained in:
Kristóf Tóth
2018-02-21 15:32:24 +01:00
parent 72223215cd
commit 8d2f19f062
5 changed files with 12 additions and 12 deletions

View File

@ -11,7 +11,7 @@ export class FSMUpdateService {
constructor(private websocketService: WebSocketService) {}
public init(): void {
this.websocketService.observeAnchor<FSMUpdate>('FSMUpdate').subscribe((event) => {
this.websocketService.observeKey<FSMUpdate>('FSMUpdate').subscribe((event) => {
this.current_state = event.data.current_state;
this.valid_transitions = event.data.valid_transitions;
});

View File

@ -41,17 +41,17 @@ export class WebSocketService {
console.log('ws connected');
}
public observeAnchor<T>(anchor: string): Observable<WSMessage<T>> {
return this.downlink.pipe(filter(message => message.anchor === anchor));
public observeKey<T>(key: string): Observable<WSMessage<T>> {
return this.downlink.pipe(filter(message => message.key === key));
}
public send(anchor: string, data: any): void {
public send(key: string, data: any): void {
// If the WebSocket is not connected then the QueueingSubject will ensure
// that messages are queued and delivered when the WebSocket reconnects.
// A regular Subject can be used to discard messages sent when the WebSocket
// is disconnected.
this.uplink.next({
'anchor': anchor,
'key': key,
'data': data
});
}

View File

@ -1,4 +1,4 @@
export class WSMessage<T> {
anchor: string;
key: string;
data: T; // TODO: sane annotation
}