[]
        
(Showing Draft Content)

GC.Spread.CalcEngine.Functions.AsyncFunction

Class: AsyncFunction

CalcEngine.Functions.AsyncFunction

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new AsyncFunction(name, minArgs?, maxArgs?, description?)

Represents an abstract base class for defining asynchronous functions.

example

class WeatherFunction extends GC.Spread.CalcEngine.Functions.AsyncFunction {
    constructor () {
        super('WEATHER', 0, 0, {
            description: "Get Weather",
            parameters: []
        });
    }
    evaluate (context) {
        setTimeout(function () { context.setAsyncResult('sunny'); }, 100);
    }
}
spread.addCustomFunction(new WeatherFunction());
spread.getActiveSheet().setFormula(0, 0, '=WEATHER()');

Parameters

Name Type Description
name string The name of the function.
minArgs? number -
maxArgs? number -
description? IFunctionDescription -

Overrides

Function.constructor

Properties

maxArgs

maxArgs: number

Represents the maximum number of arguments for the function.

Inherited from

Function.maxArgs


minArgs

minArgs: number

Represents the minimum number of arguments for the function.

Inherited from

Function.minArgs


name

name: string

Represents the name of the function.

Inherited from

Function.name


typeName

typeName: string

Represents the type name string used for supporting serialization.

Inherited from

Function.typeName

Methods

acceptsArray

acceptsArray(argIndex): boolean

Determines whether the function accepts array values for the specified argument.

function

Parameters

Name Type Description
argIndex number Index of the argument.

Returns

boolean

true if the function accepts array values for the specified argument; otherwise, false.

Inherited from

Function.acceptsArray


acceptsError

acceptsError(argIndex): boolean

Indicates whether the function can process Error values.

function

Parameters

Name Type Description
argIndex number Index of the argument.

Returns

boolean

true if the function can process Error values for the specified argument; otherwise, false.

Inherited from

Function.acceptsError


acceptsMissingArgument

acceptsMissingArgument(argIndex): boolean

Indicates whether the Evaluate method can process missing arguments.

Parameters

Name Type Description
argIndex number Index of the argument

Returns

boolean

true if the Evaluate method can process missing arguments; otherwise, false.

Inherited from

Function.acceptsMissingArgument


acceptsReference

acceptsReference(argIndex): boolean

Determines whether the function accepts Reference values for the specified argument.

function

Parameters

Name Type Description
argIndex number Index of the argument.

Returns

boolean

true if the function accepts Reference values for the specified argument; otherwise, false.

Inherited from

Function.acceptsReference


defaultValue

defaultValue(): any

Returns the default value of the evaluated function result before getting the async result.

Returns

any

The default value of the evaluated function result before getting the async result.


description

description(): IFunctionDescription

Returns the description of the function.

function

Returns

IFunctionDescription

The description of the function.

Inherited from

Function.description


evaluate

evaluate(...args): any

Returns the result of the function applied to the arguments.

Parameters

Name Type Description
...args any Arguments for the function evaluation

Returns

any

The result of the function applied to the arguments.

Inherited from

Function.evaluate


evaluateAsync

evaluateAsync(context, args): any

Returns the result of the function applied to the arguments.

Parameters

Name Type Description
context AsyncEvaluateContext The evaluate context
args any Arguments for the function evaluation

Returns

any

The result of the function applied to the arguments.


evaluateMode

evaluateMode(): AsyncFunctionEvaluateMode

Decides how to re-calculate the formula.

Returns

AsyncFunctionEvaluateMode

The evaluate mode.


findBranchArgument

findBranchArgument(test): number

Finds the branch argument.

example

function EqualsFunction() {
    this.name = 'Equals';
    this.maxArgs = 3;
    this.minArgs = 3;
}
EqualsFunction.prototype = new GC.Spread.CalcEngine.Functions.Function();
EqualsFunction.prototype.evaluate = function(logicalTest, valueIfTrue, valueIfFalse) {
    return logicalTest ? valueIfTrue : valueIfFalse;
}
EqualsFunction.prototype.isBranch = function() {
    return true;
}
EqualsFunction.prototype.findTestArgument = function() {
    return 0;
}
EqualsFunction.prototype.findBranchArgument = function(logicalTestResult) {
    if (logicalTestResult === true) {
        return 1;
    }
    return 2;
}
var equalsFunction = new EqualsFunction();
var spread = GC.Spread.Sheets.findControl("ss") || GC.Spread.Sheets.findControl("sampleDiv");
spread.addCustomFunction(equalsFunction);

Parameters

Name Type Description
test any The test.

Returns

number

Indicates the index of the argument that would be treated as the branch condition.

Inherited from

Function.findBranchArgument


findTestArgument

findTestArgument(): number

Finds the test argument when this function is branched.

example

function EqualsFunction() {
    this.name = 'Equals';
    this.maxArgs = 3;
    this.minArgs = 3;
}
EqualsFunction.prototype = new GC.Spread.CalcEngine.Functions.Function();
EqualsFunction.prototype.evaluate = function(logicalTest, valueIfTrue, valueIfFalse) {
    return logicalTest ? valueIfTrue : valueIfFalse;
}
EqualsFunction.prototype.isBranch = function() {
    return true;
}
EqualsFunction.prototype.findTestArgument = function() {
    return 0;
}
EqualsFunction.prototype.findBranchArgument = function(logicalTestResult) {
    if (logicalTestResult === true) {
        return 1;
    }
    return 2;
}
var equalsFunction = new EqualsFunction();
var spread = GC.Spread.Sheets.findControl("ss") || GC.Spread.Sheets.findControl("sampleDiv");
spread.addCustomFunction(equalsFunction);

Returns

number

Indicates the index of the argument that would be treated as the test condition.

Inherited from

Function.findTestArgument


interval

interval(): number

Returns the interval.

Returns

number

The interval in milliseconds.


isBranch

isBranch(): boolean

Gets a value that indicates whether this function is branched by arguments as conditional.

example

function EqualsFunction() {
    this.name = 'Equals';
    this.maxArgs = 3;
    this.minArgs = 3;
}
EqualsFunction.prototype = new GC.Spread.CalcEngine.Functions.Function();
EqualsFunction.prototype.evaluate = function(logicalTest, valueIfTrue, valueIfFalse) {
    return logicalTest ? valueIfTrue : valueIfFalse;
}
EqualsFunction.prototype.isBranch = function() {
    return true;
}
EqualsFunction.prototype.findTestArgument = function() {
    return 0;
}
EqualsFunction.prototype.findBranchArgument = function(logicalTestResult) {
    if (logicalTestResult === true) {
        return 1;
    }
    return 2;
}
var equalsFunction = new EqualsFunction();
var spread = GC.Spread.Sheets.findControl("ss") || GC.Spread.Sheets.findControl("sampleDiv");
spread.addCustomFunction(equalsFunction);

Returns

boolean

true if this instance is branched; otherwise, false.

Inherited from

Function.isBranch


isContextSensitive

isContextSensitive(): boolean

Determines whether the evaluation of the function is dependent on the context in which the evaluation occurs.

Returns

boolean

true if the evaluation of the function is dependent on the context; otherwise, false.

Inherited from

Function.isContextSensitive


isVolatile

isVolatile(): boolean

Determines whether the function is volatile while it is being evaluated.

Returns

boolean

true if the function is volatile; otherwise, false.

Inherited from

Function.isVolatile