methodCall
Description
Runs the method using the object assigned in context parameter.
Input / Parameter
context
This is the context (object) that the method will run on.
Object
-
-
Yes
method
The method to run or call.
Object
-
-
Yes
arguments
The arguments that will be passed to method.
Array/List
-
-
Yes
Output
The return type of methodCall depends on the function that is passed as the method. Specifically, it will return the result of invoking the method with the given context and arguments.
Any
Example
In this example, we will use function methodCall
to add a new div element in the document body by getting document
object using resolveJSName
function.
Code Equivalent
Steps
Drag a
button
component into the canvas and open theAction
tab. Select thepress
event of the button and drag thesetVar
function to the event flow.On
setVar
functionvar
param adddiv
as the value and on it'svalue
param add a subflow and drag a functionmethodCall
.On it's
context
param add a subflow and drag a functionresolveJSName
, on it'sname
param add the valuedocument
.On it's
method
param add a subflow and drag a functionobjectAttr
, on it'sobject
param add a subflow and drag a functionresolveJSName
, on it'sname
param add the valuedocument
. Back on the functionobjectAttr
on it'sattr
param add the valuecreateElement
.On it's
arguments
param add a subflow and drag a functiontoArray
, on it'svalue1
param add the valuediv
.Back to main flow, drag the
setObjectAttr
function to the event flow, on it'sobject
param add a subflow and drag a functiongetVar
, on it'svar
param add the valuediv
. As for theattr
param add the valueclassName
and for thevalue
param add the valueclass
.Back to main flow, drag the
methodCall
function to the event flow, on it'scontext
param add a subflow and drag a functionresolveJSName
, on it'sname
param add the valuedocument.body
.On it's
method
param add a subflow and drag a functionobjectAttr
, on it'sobject
param add a subflow and drag a functionresolveJSName
, on it'sname
param add the valuedocument.body
. Back on the functionobjectAttr
on it'sattr
param add the valueappendChild
.On it's
arguments
param add a subflow and drag a functiontoArray
, on it'svalue1
param add a subflow and drag a functiongetVar
, on it'svar
param add the valuediv
.
Result
Now click the button in preview, check the inspector, you will see a new div element being added on the body
Links
Related Information
See also:
Functions
Last updated