ctrl + k
On This Page
toggle
Boolean Helpers
Boolean Helpers are methods available on ReactiveVar instances that contain boolean values. These helpers provide a convenient way to toggle the state of a boolean reactive variable.
toggle
Switches the boolean value of the ReactiveVar to its opposite state.
Syntax
Returns
boolean - The new value after toggling.
Usage
Notes
- The
toggle()
method is particularly useful for managing binary states in your application, such as showing/hiding elements, enabling/disabling features, or switching between two modes. - It provides a clean and readable way to flip boolean states without explicitly checking and setting the opposite value.
- Remember that like all ReactiveVar modifications, using
toggle()
will trigger any reactive computations that depend on this variable.