Skip to Content

@ApiServiceObservable

Marks a service as observable so function subscribers are executed before/after each CRUD method and whenever an error occurs. Without this decorator, ApiFunctionSubscriber classes are ignored for the service.

Signature

@ApiServiceObservable()

Behavior

  • Adds the SERVICE_API_DECORATOR_CONSTANT.OBSERVABLE_METADATA_KEY flag to the service constructor.
  • ApiFunctionSubscriber registries inspect this metadata before invoking subscribers, preventing accidental fan-out on services that are not opt-in.
  • Works with both @ApiService-generated methods and custom methods that manually execute ApiSubscriberExecutor.

Example

@Injectable() @ApiService({ entity: PostEntity }) @ApiServiceObservable() export class PostService extends ApiServiceBase<PostEntity> {}
Last updated on