# dbus/subscribe Subscribe a closure to broadcast signals matching a D-Bus match rule (`AddMatch`). Signals are delivered while the VM event loop is pumped (e.g. during `await`, `sleep`, or `vwait`). ## Syntax
[dbus/subscribe $conn "type='signal',interface='org.example.X'" $closure]
## Parameters - `$conn` — connection from `dbus/connect` - `$rule` — match rule string; `arg0=` namespace matching is supported - `$closure` — `{|ev| ...}` receiving a map: - `:sender`, `:path`, `:interface`, `:member` — strings - `:args` — vector of demarshaled signal arguments (always present) - `:destination` — only for directed signals Re-subscribing with the same rule replaces the previous closure. ## Examples
[dbus/subscribe $conn "type='signal',interface='org.deft.Test',member='Ping'" {|ev|
  echo $ev~member [get $ev~args 0]
}]
[dbus/emit $conn2 "/org/deft/Test" "org.deft.Test" "Ping" "s" "payload"]
# closure receives %{ :member "Ping" :args @{"payload"} ... }
## Returns `nil`, or `%Err{:message}` on a bad connection, non-string rule, nil closure, or a failed `AddMatch`. ## See Also `dbus/unsubscribe`, `dbus/emit`, `dbus/call`