---
title: "publisher(for:on:componentType:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/scene/publisher(for:on:componenttype:)"
---

# publisher(for:on:componentType:)

Returns a Publisher for events of the specified type in a Scene.

## Declaration

```swift
@MainActor @preconcurrency func publisher<E>(for event: E.Type, on sourceObject: (any EventSource)? = nil, componentType: (any Component.Type)?) -> Scene.Publisher<E> where E : Event
```

## Parameters

- `event`: The event type to subscribe to. For example, doc://com.apple.RealityKit/documentation/RealityKit/SceneEvents/Update.
- `sourceObject`: The event source – usually the entity you are interested in. nil to listen all events of this type that occur in the scene.
- `componentType`: The component type, or nil for all (for ComponentEvents).

## Return Value

Return Value A Publisher for events of the specified type.

## See Also

### Publishing and subscribing to events

- [publisher(for:on:)](realitykit/scene/publisher(for:on:).md)
- [subscribe(to:on:_:)](realitykit/scene/subscribe(to:on:_:).md)
- [subscribe(to:on:componentType:_:)](realitykit/scene/subscribe(to:on:componenttype:_:).md)
