# EventingSubscriberRegistrationContext

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

Context passed to ATS-friendly eventing subscriber registrations.

## Definition

```typescript
interface EventingSubscriberRegistrationContext {
  readonly cancellationToken: cancellationToken;
  readonly executionContext: DistributedApplicationExecutionContext;
  onAfterPublish(callback: (arg: AfterPublishEvent) => Promise<void>): DistributedApplicationEventSubscription;
  onAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise<void>): DistributedApplicationEventSubscription;
  onBeforePublish(callback: (arg: BeforePublishEvent) => Promise<void>): DistributedApplicationEventSubscription;
  onBeforeStart(callback: (arg: BeforeStartEvent) => Promise<void>): DistributedApplicationEventSubscription;
}
```

## Properties

- `cancellationToken`: `cancellationToken` `get` -- The cancellation token associated with the subscriber registration.
- `executionContext`: [DistributedApplicationExecutionContext](/reference/api/typescript/aspire.hosting/distributedapplicationexecutioncontext.md) `get` -- The execution context for the AppHost invocation.

## Methods

- [onAfterPublish](/reference/api/typescript/aspire.hosting/eventingsubscriberregistrationcontext/onafterpublish.md) -- `method` -- Subscribes to the AfterPublish event from an eventing subscriber registration context.
    ```typescript
  onAfterPublish(callback: (arg: AfterPublishEvent) => Promise<void>): DistributedApplicationEventSubscription
  ```
- [onAfterResourcesCreated](/reference/api/typescript/aspire.hosting/eventingsubscriberregistrationcontext/onafterresourcescreated.md) -- `method` -- Subscribes to the AfterResourcesCreated event from an eventing subscriber registration context.
    ```typescript
  onAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise<void>): DistributedApplicationEventSubscription
  ```
- [onBeforePublish](/reference/api/typescript/aspire.hosting/eventingsubscriberregistrationcontext/onbeforepublish.md) -- `method` -- Subscribes to the BeforePublish event from an eventing subscriber registration context.
    ```typescript
  onBeforePublish(callback: (arg: BeforePublishEvent) => Promise<void>): DistributedApplicationEventSubscription
  ```
- [onBeforeStart](/reference/api/typescript/aspire.hosting/eventingsubscriberregistrationcontext/onbeforestart.md) -- `method` -- Subscribes to the BeforeStart event from an eventing subscriber registration context.
    ```typescript
  onBeforeStart(callback: (arg: BeforeStartEvent) => Promise<void>): DistributedApplicationEventSubscription
  ```
