React SDK

useVariables

useVariables provide a way for user to modify the Variables instance directly.

Usage

The get() method return the variables as an object.

Editable Example
{"q":"","resultsPerPage":"15","fields":"","filter":"_id != \"\"","countFilters":"","buckets":"","count":"","min":"","max":""}

Setting value

Use set() method to set value.

You can in fact set any arbitrary key/value pair but some propertys are reserved and will be picked up by the pipeline backend.

The following key/value pairs are reserved:

The object passed in will be merged with the current value, any key with undefined value will remove that key from the Variables instance.

Editable Example
{"q":"","resultsPerPage":"15","fields":"","filter":"_id != \"\"","countFilters":"","buckets":"","count":"","min":"","max":""}

Listening

You can also attach callback to the Variables instance when something changes. The return value of listen() is a unlisten function making it easy to cleanup.

Editable Example

Check your console!

Anatomy

useVariables returns an object containing the following properties:

NameTypeDefaultDescription
variablesVariablesThe Variables instance

Parameters

NameTypeDefaultDescription