mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
40 lines
1002 B
TypeScript
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);
|
|
}
|
|
}
|