# hypr/subscribe Subscribe a closure to a named Hyprland event. The closure receives `%{ :name "workspace" :payload "json…" }`; `:payload` is the raw second line of the event (empty string when the event carries no payload), so parse it with `json/parse` when it is JSON. Re-subscribing to the same name replaces the previous closure. ## Syntax
[hypr/subscribe $h "workspace" $closure]
## Parameters - `$h` — connection from `hypr/connect` - `$name` — event name, e.g. `"workspace"`, `"activewindow"`, `"fullscreen"` - `$closure` — `{|ev| ...}` invoked on delivery ## Examples
[hypr/subscribe $h "workspace" {|ev|
  echo $ev~name [json/parse $ev~payload]
}]
[hypr/send $h "emit events"]      # test fake: forces events
[await [hypr/call $h "ping"]]     # pump the loop until delivered
## Returns `nil`, or `%Err{:message}` on a closed connection, non-string event name, or nil closure. ## See Also `hypr/unsubscribe`, `hypr/call`, `hypr/connect`