Skip to content

The Context Object

Almost all the APIs of Refina.js are provided via the context object.

It is used to render components, handle events, etc.

The context object has three kinds of properties:

  • Component functions: used to render components.
  • Utility functions: used to do some useful things.
  • Directives: some special properties and methods.

WARNING

If you want to use non-directive properties, you MUST name the context object as _.

Otherwise, the transformation will not work, and errors will occur at runtime.

Component Functions

The only way to render components is to call the corresponding component function.

There are three kinds of component functions:

  1. Text node: _.t.
  2. Lowlevel elements: _._div, _._svgPath, whose names are prefixed with _.
  3. Component functions provided by plugins: _.button provided by Basics, _.mdButton provided by MdUI, etc. Whose names don't have the _ prefix.

Utility Functions

These functions are used to do some useful things, like controlling the rendering process, set a timer, etc.

Their names also don't have the _ prefix.

See Utility Context Functions for utility functions provided by the Refina Core.

Directives

Directives are some special properties and methods of the context object.

They are prefixed with $, and they are not transformed when compiling.

See Directives for directives provided by the Refina Core.