File

libs/video-stat-dashboard/src/services/views-filter.service.ts

Index

Properties
Methods

Constructor

constructor(store: Store)
Parameters :
Name Type Optional
store Store<VideoStatsState> no

Methods

setDateFrom
setDateFrom(dateFrom: number)
Parameters :
Name Type Optional
dateFrom number no
Returns : void
setDateTo
setDateTo(dateTo: number)
Parameters :
Name Type Optional
dateTo number no
Returns : void
setRegion
setRegion(region: string)
Parameters :
Name Type Optional
region string no
Returns : void
toggleAge
toggleAge(index: number)
Parameters :
Name Type Optional
index number no
Returns : void

Properties

age
age:
Default value : this.store.select(state => state.videoStats.viewsFilter.ageRanges)
dateFrom
dateFrom:
Default value : this.store.select(state => state.videoStats.viewsFilter.dateFrom)
dateTo
dateTo:
Default value : this.store.select(state => state.videoStats.viewsFilter.dateTo)
filterState
filterState:
Default value : this.store.select(state => state.videoStats.viewsFilter)
region
region:
Default value : this.store.select(state => state.videoStats.viewsFilter.region)
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';

import { VideoStatsState } from '../+state/video-stats.interfaces';

@Injectable()
export class ViewsFilterService {

  filterState = this.store.select(state => state.videoStats.viewsFilter);
  region = this.store.select(state => state.videoStats.viewsFilter.region);
  dateFrom = this.store.select(state => state.videoStats.viewsFilter.dateFrom);
  dateTo = this.store.select(state => state.videoStats.viewsFilter.dateTo);
  age = this.store.select(state => state.videoStats.viewsFilter.ageRanges);

  constructor(private store: Store<VideoStatsState>) { }

  setRegion(region: string) {
    this.store.dispatch({
      type: 'CHANGE_REGION',
      payload: region
    });
  }

  setDateFrom(dateFrom: number) {
    this.store.dispatch({
      type: 'CHANGE_DATE_FROM',
      payload: dateFrom
    });
  }

  setDateTo(dateTo: number) {
    this.store.dispatch({
      type: 'CHANGE_DATE_TO',
      payload: dateTo
    });
  }

  toggleAge(index: number) {
    this.store.dispatch({
      type: 'TOGGLE_AGE',
      payload: index
    });
  }
}

results matching ""

    No results matching ""