# Call one browser-side method on a target element

Sends a one-way command from the Shiny server that invokes a
browser-side method on the element identified by DOM `id`.

## Usage

``` r
wa_call_method(
  id,
  method,
  args = list(),
  session = shiny::getDefaultReactiveDomain()
)
```

## Arguments

- id:

  DOM `id` of the target browser element.

- method:

  Scalar method name to invoke on the target element.

- args:

  Optional list of positional arguments to pass to the method. These
  should be serializable through Shiny's custom-message transport. In
  practice, prefer JSON-like scalar values or nested lists that map
  cleanly to browser values. Do not expect R functions, language
  objects, or HTML tags to serialize into useful method arguments.

- session:

  Shiny session object. Defaults to the current reactive domain.

## Value

Invisibly returns `NULL`.

## Details

`wa_call_method()` is a narrow package-level escape hatch for advanced
cases where a Web Awesome component method needs to be triggered from
server logic but is not covered by a generated helper. It does not
validate whether the requested method exists for the targeted component.

This helper is complementary to generated component bindings and update
helpers. It is not part of upstream component coverage and does not
expand the generated per-component API surface.

On the server side, `wa_call_method()` validates only its R helper
inputs, such as the target `id`, method name, argument list, and
session. It does not validate whether the requested method exists on the
browser-side element.

In the browser runtime, the command layer validates that the target DOM
`id` resolves to an element, that a method name was supplied, and that
the named member is callable on the target element before invoking it.
Command-layer warnings are controlled by the package warning registry,
especially the `command_layer` key. For option details, see the Package
Options article.

## Examples

``` r
# \donttest{
library(shiny)
library(shiny.webawesome)

ui <- webawesomePage(
  wa_button("Show dialog", id = "show_dialog"),
  wa_dialog("Dialog body", id = "dialog")
)

server <- function(input, output, session) {
  observeEvent(input$show_dialog, {
    wa_call_method("dialog", "show", session = session)
  })
}

app <- shinyApp(ui, server)
stopifnot(inherits(app, "shiny.appobj"))

# Run `app` interactively to launch this example application.
# }
```
