<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Scene/publisher(for:on:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation5SceneC9publisher3for2onAC9PublisherVy_xGxm_AA11EventSource_pSgtAA0H0RzlF"
  },
  "title" : "publisher(for:on:)"
}
-->

# publisher(for:on:)

Generates a publisher for events of the specified type.

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

## Parameters

`event`

The event, like `SceneEvents.Update.self`.

`sourceObject`

The source of the event. Set to `nil` to publish all
events of the given type within the scene.

## Return Value

A publisher for events of the specified type.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)