import { Action } from '@ngrx/store' ; import { TypedAction } from '@ngrx/store/src/models' ; import { DEFAULT_GENERIC_RETRY_STRATEGY , GenericRetryStrategyOptions } from '../utils/generic-retry-strategy.util' ; import { md5 } from '../utils/md5.util' ; /**
 * Abstract Effects
 */ export abstract class AbstractEffects < T = any > { /**
     * Generic retry strategy options
     */ protected genericRetryStrategyOptions = DEFAULT_GENERIC_RETRY_STRATEGY ; protected constructor ( protected readonly key ) { } param payload getIdByPayload ( payload ) { return md5 ( JSON . stringify ( payload ) ) ; } param state param key getState < S = T > ( state , key ? ) { return state [ key || this . key ] ; } param options setRetryStrategyOptions ( options ) { this . genericRetryStrategyOptions = { ... this . genericRetryStrategyOptions , ... options } ; } param action param error param responseAction param debug errorHandler ( action , error = { } , responseAction ? , debug = false ) { if ( debug ) { console . error ( error ) ; } if ( responseAction ) { return responseAction ( { payload : error } ) ; } } }