funky-framadate-front/src/app/core/services/poll.service.ts
2020-04-25 17:47:00 +02:00

40 lines
1002 B
TypeScript

import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { Poll } from '../models/poll.model';
import { ApiService } from './api.service';
@Injectable({
providedIn: 'root',
})
export class PollService {
private _poll: BehaviorSubject<Poll | undefined> = new BehaviorSubject<Poll | undefined>(undefined);
public readonly poll: Observable<Poll | undefined> = this._poll.asObservable();
constructor(private apiService: ApiService) {}
public updateCurrentPoll(poll: Poll): void {
this._poll.next(poll);
}
public savePoll(poll: Poll): void {
this.apiService.savePoll(poll);
}
public saveVote(poll: Poll): void {
this.apiService.saveVote(poll);
}
public saveComment(poll: Poll, comment: string): void {
this.apiService.saveComment(poll, comment);
}
public deletePollVotes(poll: Poll): void {
this.apiService.deletePollVotes(poll);
}
public deletePollComments(poll: Poll): void {
this.apiService.deletePollComments(poll);
}
}