NativeRequest
An owned asynchronous native request with explicit cancellation.
Advanced app/host integration API. Useful for lower-level work; ordinary app authors can start with the app-building path. This is public API, not permission to access private toolkit objects.
Example
Section titled “Example”Low-level public host protocol. In preview.2, add Storage.ApplicationId as shown below. Preview.1 needs a custom embedding host that installs the storage provider; its standard SDK cannot provision this scope.
Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.
Project setup: add Storage to Capabilities in lui.json. This example requires a custom host that installs storage; the ordinary preview.1 runner cannot provision it. See the capability guide.
local Window = Instance.new("Window", { Title = "LUI example", Size = UDim2.fromOffset(560, 280),})local Status = Instance.new("TextLabel", { Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170), Size = UDim2.new(1, -32, 0, 72),})local Storage = app:GetService("StorageService")local Request = Storage:Open(buffer.fromstring("example_note"), nil, function(_, Handle, Failure) if Handle then Handle:Close() end -- Close a handle if completion won the race.end)local Won, Code = Request:Cancel()Status.Text = "Cancellation won: " .. tostring(Won) .. "; status: " .. CodeWindow.Visible = trueExpected result: Shows the result of canceling a native request. A completed operation cannot be rolled back by canceling its request.
Behavior and limits
Section titled “Behavior and limits”- Receive a request from a native callback service; do not construct one. Cancellation retires pending work, but is not a general rollback mechanism.
Methods
Section titled “Methods”Cancel
Section titled “Cancel”Requests cancellation and returns whether it won plus a status string. It cannot undo an already completed side effect or forcibly stop arbitrary native code.
Cancel() -> (boolean, string)Full type declaration — for type checking and deeper reference
The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.
export type NativeRequest = { read Cancel: (Self: NativeRequest) -> (boolean, string),}Availability and deeper reading
Section titled “Availability and deeper reading”See platform limits before relying on host-specific behavior. The framework design specification and reflection/type sources are deeper engineering references, not extra setup required to build an app.