Constructor
new Procedure(procedure)
Creates a new procedure caller function. This function can be called either as a constructor or as a plain function. In both cases it returns a new JavaScript function with additional methods.
- Properties:
-
Name Type Description procedure
{string} The procedure name. args
{Array} The arguments used in the last call. - Parameters:
-
Name Type Description procedure
{string} the procedure name - Source:
- RapidContext_Procedure.js, line 17
Methods
cancel()
Cancels any current execution of this procedure. This method does nothing if no procedure call was currently executing.
- Parameters:
-
Type Description - Source:
- RapidContext_Procedure.js, line 222
multicall(args, transformopt) → {Promise}
Calls the procedure multiple times (in sequence) with different arguments
(supplied as an array of argument arrays). The calls are asynchronous, so
results will not be returned by this method. Instead an array with the
results will be available through the onupdate
and onsuccess
signals,
for example.
Note that any previously running call will automatically be cancelled, since
only a single call can be processed at any time. A result transform
function can be supplied to transform each individual result. If the
transform
function throws an error, that result will be omitted.
- Parameters:
-
Name Type Attributes Description args
{Array} the array of argument arrays transform
{function} <optional>
the optional result transform function - Returns:
-
{Promise}
a
RapidContext.Async
promise that will resolve with the response data or error - Source:
- RapidContext_Procedure.js, line 172
recall() → {Promise}
Calls the procedure with the same arguments as used in the last call. The
call is asynchronous, so results will not be returned by this method.
Instead the results will be available through the onsuccess
signal, for
example.
Note that any previously running call will automatically be cancelled, since only a single call can be processed at any time.
- Parameters:
-
Type Description - Returns:
-
{Promise}
a
RapidContext.Async
promise that will resolve with the response data or error - Source:
- RapidContext_Procedure.js, line 129
reset()
Cancels any current execution and removes the reference to the arguments of this procedure.
- Parameters:
-
Type Description - Source:
- RapidContext_Procedure.js, line 238
(static) mapAll(obj) → {Object}
Creates a new procedure caller for each key-value-pair in the specified object.
- Parameters:
-
Name Type Description obj
{Object} an object mapping keys to procedure names - Returns:
- {Object} an object mapping keys to procedure instances
- Source:
- RapidContext_Procedure.js, line 251
Events
oncall
Emitted when the procedure is called. Each call corresponds to exactly one
oncall
and one onresponse
event (even if the call was cancelled). No
event data will be sent.
- Source:
- RapidContext_Procedure.js, line 57
oncancel
Emitted when a procedure call was cancelled. This event is emitted after the
onresponse
event, but only if the procedure call was cancelled. Use the
onsuccess
or onerror
for other result statuses. No event data will be
sent.
- Source:
- RapidContext_Procedure.js, line 106
onerror
Emitted when a procedure call failed. This event is emitted after the
onresponse
event, but only if the procedure call returned an error. Use
the onsuccess
or oncancel
for other result statuses. The call error
object will be sent as the event data.
- Source:
- RapidContext_Procedure.js, line 96
onresponse
Emitted when the procedure response has been received. Each call corresponds
to exactly one oncall
and one onresponse
event (even if the call was
cancelled). The call response or error object will be sent as the event
data.
- Source:
- RapidContext_Procedure.js, line 76
onsuccess
Emitted when a procedure call returned a result. This event is emitted after
the onresponse
event, but only if the procedure call actually succeeded.
Use the onerror
or oncancel
signals for other result statuses. The call
response object will be sent as the event data.
- Source:
- RapidContext_Procedure.js, line 86
onupdate
Emitted if a partial procedure result is available. This event will only be
emitted when performing a multi-call, along with the oncall
and
onresponse
events (for each call). The partial procedure result will be
sent as the event data.
- Source:
- RapidContext_Procedure.js, line 66