import { Injectable } from '@angular/core';
import { createEffect, Actions, ofType } from '@ngrx/effects';

import * as <%= className %>Actions from './<%= fileName %>.actions';
import * as <%= className %>Feature from './<%= fileName %>.reducer';

import {switchMap, catchError, of} from 'rxjs';

@Injectable()
export class <%= className %>Effects {
  init$ = createEffect(() => this.actions$.pipe(
    ofType(<%= className %>Actions.init<%= className %>),
    switchMap(() => of(<%= className %>Actions.load<%= className %>Success({ <%= propertyName %>: [] }))),
    catchError((error) => {
        console.error('Error', error);
        return of(<%= className %>Actions.load<%= className %>Failure({ error }));
      }
    )
  ));

  constructor(private readonly actions$: Actions) {}
}
