def emit name, *args
      # Trigger callbacks in scripts before triggering events in the client.
      EM.defer { notify_scripts name, *args }

      matching_callbacks = callbacks[name]
      return false unless matching_callbacks&.any?

      EM.defer do
        matching_callbacks.each { |callback| callback.call *args }
      end
    end
def emit name, *args
      # Trigger callbacks in scripts before triggering events in the client.
      EM.defer { notify_scripts name, *args }

      matching_callbacks = callbacks[name]
      return false unless matching_callbacks&.any?

      EM.defer do
        matching_callbacks.each { |callback| callback.call *args }
      end
    end
Emit a new event with given arguments.

 @param name [Symbol] The event name.
 @param args [optional, Array] The list of arguments to pass.
 @return [true, false] True if any callbacks were invoked, nil otherwise