Statements may have an
onInit, and must have an
onObservableprovided, and then the
definemethod must be called.
local First = Statement.named("First")
assert(resolvable ~= nil, "The First `resolveable` may not be `nil`.")
context.resolvable = resolvable
Once you've defined a statement, you then execute it by calling the statement directly, passing in any parameters.
local First = require("cp.rx.go").First
First(Observable.of(1, 2, 3))
function(value) print("Received: "..tostring(value)) end,
function(message) print("Error: "..tostring(message)) end,
function() print("Completed") end
This will output:
Observableas passed to the
onInitfunction handler as the second parameter.
contextis always the first parameter, followed by any values passed to the constructor call.
It is recommended that any conversion of input parameters are converted to
Observables as late as possible, typically in the
onObservablefunction handler. Otherwise, input values may get resolved before the user intends.
- Functions - API calls offered directly by the extension
- Constructors - API calls which return an object, typically one that offers API methods
- Methods - API calls which can only be made on an object returned by a constructor