io.group
Combines multiple I/O method calls into a single form.
Individual I/O methods await within your action until user input is provided,
such that each I/O method call results in a distinct step within the
generated app. io.group
allows you to group multiple I/O methods
together to request input all at once in a single step.
caution
io.confirm and io.confirmIdentity are not supported within an io.group
.
Custom validation can be performed on groups by chaining a .validate()
method call
to the group. Learn more about validation here.
Usage
- TypeScript
- JavaScript
- Python Experimental
const [name, email, age] = await io.group([
io.input.text("Name"),
io.input.email("Email"),
io.input.number("Age"),
]);
// or
const { name, email, age } = await io.group({
name: io.input.text("Name"),
email: io.input.email("Email"),
age: io.input.number("Age"),
});
const [name, email, age] = await io.group([
io.input.text("Name"),
io.input.email("Email"),
io.input.number("Age"),
]);
// or
const { name, email, age } = await io.group({
name: io.input.text("Name"),
email: io.input.email("Email"),
age: io.input.number("Age"),
});
name, email, age = await io.group(
io.input.text("Name"),
io.input.email("Email"),
io.input.number("Age"),
)
# or
values = await io.group(
name=io.input.text("Name"),
email=io.input.email("Email"),
age=io.input.number("Age"),
)
print("Name:", values.name)
Props
Receives an array or object of I/O method calls as its first argument.
info
Dynamic arrays are supported, but discouraged as they make the result's types not statically determinable and extracting the results difficult to reason about.
- TypeScript
- JavaScript
- Python Experimental
continueButton
objectOptional
label
stringOptional
theme
"default" | "danger"Optional
Returns
Returns an array or object (depending on input) of its constituent I/O methods' return values.
Similarly to Promise.all, if the contents are defined inline or of constant types, the return values will be correctly typed by TypeScript.
continueButton
objectOptional
label
stringOptional
theme
"default" | "danger"Optional
Returns
Returns an array or object (depending on input) of its constituent I/O methods' return values.
Returns
Returns an array or object (depending on input) of its constituent I/O methods' return values.
Examples
- TypeScript
- JavaScript
- Python Experimental
Named values
Rather than relying on the index-based values returned when providing a list of sub-components to io.group
, if you provide an object with named keys, Interval will return the results of the form as an object with values assigned to the provided key for each component. While only slightly more complicated to configure, this can be much more robust at access time or when refactoring the contents of the group.
const { name, email, age } = await io.group({
name: io.input.text("Name"),
email: io.input.email("Email"),
age: io.input.number("Age"),
});
Named values
Rather than relying on the index-based values returned when providing a list of sub-components to io.group
, if you provide an object with named keys, Interval will return the results of the form as an object with values assigned to the provided key for each component. While only slightly more complicated to configure, this can be much more robust at access time or when refactoring the contents of the group.
const { name, email, age } = await io.group({
name: io.input.text("Name"),
email: io.input.email("Email"),
age: io.input.number("Age"),
});
Named values
Rather than relying on the index-based values returned when providing unnamed sub-components to io.group
, if you provide keyword arguments Interval will return the results of the form as an object with values assigned to the provided key for each component. While only slightly more complicated to configure, this can be much more robust at access time or when refactoring the contents of the group.
Unfortunately, type inference for these keys on the returned object is not available at this time.
values = await io.group(
name=io.input.text("Name"),
email=io.input.email("Email"),
age=io.input.number("Age"),
);
print("Name:", values.name);
print("Email:", values.email);
print("Age:", values.age);
Continue button
To customize the button that completes the group's step within the action, chain a call to the continue_button_options
method on the group.
The text for the button is set via label
, and the visual theme for the button is configured via theme
.
[name, email, age] = await io.group(
io.input.text("Name"),
io.input.email("Email"),
io.input.number("Age"),
).continue_button_options(label="Delete", theme="danger")