Page MenuHomec4science

field-interaction.service.ts
No OneTemporary

File Metadata

Created
Fri, May 24, 10:55

field-interaction.service.ts

import { Word } from '../models/models';
import {EventEmitter} from '@angular/core';
import {Subject} from 'rxjs';
export class WordService {
onHoveredWord = new EventEmitter<Word>();
offHoveredWord = new EventEmitter<Word>();
oldClickedWord: Word;
onClickedWord = new EventEmitter<Word>();
private informationSource = new Subject<Word>();
wordChange$ = this.informationSource.asObservable();
updateInfo(information: Word) {
this.informationSource.next(information);
}
public onClickService(word: Word) {
if ( word !== this.oldClickedWord) {
this.onClickedWord.emit(word);
this.oldClickedWord = word;
}
}
public mouseEnterService(word: Word) {
this.onHoveredWord.emit(word);
}
public mouseLeaveService(word: Word) {
this.offHoveredWord.emit(word);
}
}

Event Timeline