async-call-rpc

A lightweight JSON RPC client & server

Home > async-call-rpc > AsyncCallOptions > thenable

AsyncCallOptions.thenable property

If the instance is “thenable”.

Signature:

thenable?: boolean;

Remarks

If this options is set to true, it will return a then method normally (forwards the request to the remote).

If this options is set to false, it will return undefined, which means a method named “then” on the remote is not reachable.

If this options is set to undefined, it will return undefined and show a warning. You must explicitly set this option to true or false to dismiss the warning.

This option is used to resolve the problem caused by Promise auto-unwrapping.

Consider this code:

async function getRPC() {
    return AsyncCall(...)
}

According to the JS semantics, it will invoke the “then” method immediately on the returning instance which is unwanted in most scenarios.

To avoid this problem, methods called “then” are omitted from the type signatures. Strongly suggest to not use “then” as your RPC method name.