rx_trigger: Reactive trigger

Description Usage Arguments Details Value Examples

View source: R/simple.R

Description

At times it can be useful to have an explicit mechanism to cause a reactive expression to invalidate. Create a reactive trigger outside of the reactive expression using rx_trigger, then have the reactive expression call the reactive trigger like a function–this will take a reactive dependency on the trigger. When you want to cause the reactive expression to invalidate, call rx_fire_trigger(trigger).

Usage

1
2
3

Arguments

rxtrig

The trigger to fire.

Details

rx_trigger is the constructor for the reactive trigger. The reactive trigger object that it produces should be called like a function from whatever reactive context wants to be triggered by it.

To fire a reactive trigger, pass it to the rx_fire_trigger function.

Value

rx_trigger returns a function-like object that you can call to take a dependency on the trigger.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
trig <- rx_trigger()

now <- rx_exec({
  trig()
  print(Sys.time())
})

rx_exec({
  shiny::invalidateLater(1000, NULL)
  rx_fire_trigger(trig)
})

jcheng5/rxtools documentation built on May 18, 2019, 10:22 p.m.