req_has_cookie {scenes} | R Documentation |
Switch Scenes on Cookies
Description
Create a scene_action
specifying a cookie that must be present (or absent)
and optionally a check function for that cookie.
Usage
req_has_cookie(cookie_name, validation_fn = NULL, ..., negate = FALSE)
Arguments
cookie_name |
The cookie that must be present, as a length-1 character vector. |
validation_fn |
A function that takes the value of the cookie as the
first parameter, and returns |
... |
Additional parameters passed on to |
negate |
If |
Value
A scene_action
object, to be used in set_scene()
.
Examples
# Specify an action to detect a cookie named "mycookie".
req_has_cookie("mycookie")
# Specify an action to detect the *lack* of a cookie named "mycookie".
req_has_cookie("mycookie", negate = TRUE)
# Specify an action to detect a cookie named "mycookie" that has 27
# characters.
req_has_cookie(
cookie_name = "mycookie",
validation_fn = function(cookie_value) {
nchar(cookie_value == 27)
}
)
# Specify an action to detect a cookie named "mycookie" that has N
# characters. This would make more sense in a case where validation_fn isn't
# an anonymous function.
req_has_cookie(
cookie_name = "mycookie",
validation_fn = function(cookie_value, N) {
nchar(cookie_value) == N
},
N = 27
)
[Package scenes version 0.1.0 Index]