You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.
A Statement is defined to enable processing of asynchronous resolvable values such
as cp.rx.Observable values.
To define a new Statement, you call the named constructor, assigning the result
to a constant value and calling the define method.
Definine a new Statement
To define a new Statement implementation, we use the Statement.named constructor.
This gives us a Statement.Definition which allows
us to set the rules for the statement before finally "defining" it.
Statements may have an onInit, and must have an onObservable provided,
and then the define method must be called.
For example, the First statement is defined like so:
localFirst=Statement.named("First")
:onInit(function(context, resolvable)
assert(resolvable~=nil, "The First `resolveable` may not be `nil`.")
context.resolvable=resolvableend)
:onObservable(function(context)
returntoObservable(context.resolvable):first()
end)
:define()
Once you've defined a statement, you then execute it by calling the statement directly, passing
in any parameters.
The Observable as passed to the onInit function handler as the second parameter.
context is always the first parameter, followed by any values passed to the constructor call.
The onObservable function handler is called once the statement is actually executing, typically
by calling the Now or After methods.
It is recommended that any conversion of input parameters are converted to Observables as
late as possible, typically in the onObservable function handler. Otherwise, input values
may get resolved before the user intends.