All files / src/app/common/ui.actions ui.actions.ts

100% Statements 23/23
50% Branches 1/2
100% Functions 8/8
100% Lines 20/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 571x 1x         1x   1x 1x 1x     28x     1x 8x           1x 8x     1x 6x           1x 6x     1x 2x                       1x 1x     1x  
import { Injectable,  } from '@angular/core';
import { NgRedux } from '@angular-redux/store';
import { IAppState } from '../../store/state/AppState';
import { UiActionType } from '../../store/actions/uiActionType';
 
@Injectable()
export class UiActions {
 
  static INCREMENT_LOADING = '[UI] INCREMENT_LOADING';
  static DECREMENT_LOADING = '[UI] DECREMENT_LOADING';
  static FOUR0FOUR_MESSAGE = '[UI] FOUR0FOUR_MESSAGE';
 
  constructor(
    private ngRedux: NgRedux<IAppState>,
  ) {}
 
  createIncrementLoading(trigger: string): UiActionType {
    return {
      type: UiActions.INCREMENT_LOADING,
      triggeringAction: trigger,
      excludeFromLog: true,
    };
  }
  incrementLoading(trigger: string) {
    this.ngRedux.dispatch(this.createIncrementLoading(trigger));
  }
 
  createDecrementLoading(trigger: string): UiActionType {
    return {
      type: UiActions.DECREMENT_LOADING,
      triggeringAction: trigger,
      excludeFromLog: true,
    };
  }
  decrementLoading(trigger: string) {
    this.ngRedux.dispatch(this.createDecrementLoading(trigger));
  }
 
  createSetFour0FourMessage(caller, message, url, methodArgs): UiActionType {
    return {
      type: UiActions.FOUR0FOUR_MESSAGE,
      payload: {
        four0four: {
          caller,
          message,
          url,
          methodArgs
        }
      }
    };
  }
  setFour0FourMessage(caller, message, url, ImethodArgs = null) {
    this.ngRedux.dispatch(this.createSetFour0FourMessage(caller, message, url, methodArgs));
  }
 
}