observePath: Observe URL paths

Description Usage Arguments 'param()' and 'query()'

View source: R/url.R

Description

Observe a URL path and run a handler expression. 'handler' is run when the browser navigates to a URL path matching 'path'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
observePath(
  path,
  handler,
  env = parent.frame(),
  quoted = FALSE,
  ...,
  domain = getDefaultReactiveDomain()
)

param(x)

query(x)

Arguments

path

A character string specifying a URL path, by default 'path' is treated as a regular expression, passed 'fixed = TRUE' to disable this behaviour.

handler

An expression or function to call when the URL path matches 'path'.

env

The parent environment of 'handler', defaults to the calling environment.

quoted

One of 'TRUE' or 'FALSE' specifying if 'handler' is a quoted expression. If 'TRUE', the expression must be quoted with 'quote()'.

...

Additional arguments passed to 'grepl()'.

domain

A reactive context, defaults to 'shiny::getDefaultReactiveDomain()'.

x

A bare name specifying a URL

'param()' and 'query()'

You may want a handler expression to use information from or pieces of a URL. Currently, two helper functions exist to extract information from the URL.

With 'param()' we can capture pieces of the URL path if 'path' is a regular expression. To capture a portion of the URL we need to use regular expression named capture groups. Here is an example, '"/about/(?<subject>[a-z]+)"'. In this example we have a param named subject. To get this value we can call 'param(subject)' in the handler expression.

With ‘query()' we can check for values in the URL’s query string. In the URL 'https://demo.org/?p=10&view=all' the query string contains 'p' and 'view' with values '10' and '"all"', respectively. To check for these values we can call 'query(p)' and 'query(view)' inside our handler expression. If the values are not present in the query string 'NULL' is returned.


nteetor/blaze documentation built on Nov. 26, 2020, 7:04 a.m.