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:
- Text node:
_.t
. - Lowlevel elements:
_._div
,_._svgPath
, whose names are prefixed with_
. - Component functions provided by plugins:
_.button
provided byBasics
,_.mdButton
provided byMdUI
, 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.