🧠
ngx-crud
  • Introduction
  • API
    • HTTP Operations
    • HTTP Aborting
    • HTTP Caching
    • HTTP Observing
    • HTTP Options
    • HTTP Context
    • HTTP Headers
    • HTTP Params
    • Service Instance
    • Service Options
  • Reference
    • Modules
      • AbortModule
      • CacheModule
      • ObserveModule
      • CrudModule
    • Services
      • AbortService
      • CacheService
      • CommonService
      • CrudService
      • CustomService
      • DeleteService
      • FindService
      • GetService
      • ObserveService
      • PatchService
      • PostService
      • PutService
    • Interceptors
      • AbortInterceptor
      • CacheInterceptor
      • ObserveInterceptor
    • Decorators
      • @ApiUrl
      • @ApiRoute
    • Helpers
      • createUrl
      • createUrlWithId
      • stripUrlParams
  • Examples
    • Services
      • Fully Typed Collection
      • Limited Singleton
    • Components
      • Loader
    • Effects
      • ProfilerEffect
      • ErrorEffect
      • OfflineEffect
  • Links
    • GitHub
Powered by GitBook
On this page
  1. Examples

Effects

Provide the EffectService inside your AppModule:

import { NgModule } from '@angular/core';
import { OBSERVE_EFFECT } from 'ngx-crud';
import { ExampleEffect } from './example.effect';

@NgModule(
{
	providers:
	[
		{
			provide: OBSERVE_EFFECT,
			useClass: ExampleEffect
		}
	]
})
export class AppModule
{
}

Implement the ExampleEffect as needed:

import { Injectable } from '@angular/core';
import { HttpErrorResponse, HttpRequest, HttpResponse } from '@angular/common/http';
import { ObserveBeforeEffect, ObserveAfterEffect } from 'ngx-crud';

@Injectable()
export class ExampleEffect implements ObserveBeforeEffect, ObserveAfterEffect
{
	before<T>(request : HttpRequest<T>) : HttpRequest<T>
	{
	}

	after<T>(request : HttpRequest<T>, response : HttpResponse<T> | HttpErrorResponse) : void
	{
	}
}

Enable observing for the service:

exampleService->enableObserve();
PreviousLoaderNextProfilerEffect

Last updated 3 months ago