|
@@ -7,7 +7,13 @@ import { GlobalBus } from "./global"
|
|
|
export namespace Bus {
|
|
export namespace Bus {
|
|
|
const log = Log.create({ service: "bus" })
|
|
const log = Log.create({ service: "bus" })
|
|
|
type Subscription = (event: any) => void
|
|
type Subscription = (event: any) => void
|
|
|
- const disposedEventType = "server.instance.disposed"
|
|
|
|
|
|
|
+
|
|
|
|
|
+ export const InstanceDisposed = BusEvent.define(
|
|
|
|
|
+ "server.instance.disposed",
|
|
|
|
|
+ z.object({
|
|
|
|
|
+ directory: z.string(),
|
|
|
|
|
+ }),
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
const state = Instance.state(
|
|
const state = Instance.state(
|
|
|
() => {
|
|
() => {
|
|
@@ -21,7 +27,7 @@ export namespace Bus {
|
|
|
const wildcard = entry.subscriptions.get("*")
|
|
const wildcard = entry.subscriptions.get("*")
|
|
|
if (!wildcard) return
|
|
if (!wildcard) return
|
|
|
const event = {
|
|
const event = {
|
|
|
- type: disposedEventType,
|
|
|
|
|
|
|
+ type: InstanceDisposed.type,
|
|
|
properties: {
|
|
properties: {
|
|
|
directory: Instance.directory,
|
|
directory: Instance.directory,
|
|
|
},
|
|
},
|
|
@@ -32,13 +38,6 @@ export namespace Bus {
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- export const InstanceDisposed = BusEvent.define(
|
|
|
|
|
- disposedEventType,
|
|
|
|
|
- z.object({
|
|
|
|
|
- directory: z.string(),
|
|
|
|
|
- }),
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
export async function publish<Definition extends BusEvent.Definition>(
|
|
export async function publish<Definition extends BusEvent.Definition>(
|
|
|
def: Definition,
|
|
def: Definition,
|
|
|
properties: z.output<Definition["properties"]>,
|
|
properties: z.output<Definition["properties"]>,
|