import { Injectable } from '@angular/core';
import { Effect, Actions } from '@ngrx/effects';
import { DataPersistence } from '@nrwl/angular';

import { <%= className %>PartialState  } from './<%= fileName %>.reducer';
import { Load<%= className %>, <%= className %>Loaded, <%= className %>LoadError, <%= className %>ActionTypes } from './<%= fileName %>.actions';

@Injectable()
export class <%= className %>Effects {
 @Effect() load<%= className %>$ = this.dataPersistence.fetch(<%= className %>ActionTypes.Load<%= className %>, {
   run: (action: Load<%= className %>, state: <%= className %>PartialState) => {
     // Your custom REST 'load' logic goes here. For now just return an empty list...
     return new <%= className %>Loaded([]);
   },

   onError: (action: Load<%= className %>, error) => {
     console.error('Error', error);
     return new <%= className %>LoadError(error);
   }
 });

 constructor(
   private actions$: Actions,
   private dataPersistence: DataPersistence<<%= className %>PartialState>) { }
}
