const [iban, paymentId] = client.atomic((client, { variable, pluck }) => {
// Defines a variable to store the IBAN. Note that this is syntactic sugar for what will happen
// during the request.
const iban = variable<string>("iban");
// Defines the array of requests the server must process. This is all bundled up and sent as a
// single request.
return [
// Firstly, we will store something in the array by getting an item, plucking a key, and then
// storing the variable. The server gets the pluck info, so it can optimise here if it wishes.
// No requirement, though.
iban.store(pluck(client.charities.getByName("AKT"), "iban")),
// Now say we want to add that IBAN to a list. This would typically require 2 API calls, but we
// have the variable here (it NEEDS to be set first). Lets use that to add it to the list. Note
// that this is atomic, and using the database transaction hook on the backend (or commit/rollback
// hooks).
client.payments.makeIbanPayment(iban, 100),
] as const;
});
const [iban, paymentId] = client.atomic((client, { variable, pluck }) => {
// Defines a variable to store the IBAN. Note that this is syntactic sugar for what will happen
// during the request.
const iban = variable<string>("iban");
// Defines the array of requests the server must process. This is all bundled up and sent as a
// single request.
return [
// Firstly, we will store something in the array by getting an item, plucking a key, and then
// storing the variable. The server gets the pluck info, so it can optimise here if it wishes.
// No requirement, though.
iban.store(pluck(client.charities.getByName("AKT"), "iban")),
// Now say we want to add that IBAN to a list. This would typically require 2 API calls, but we
// have the variable here (it NEEDS to be set first). Lets use that to add it to the list. Note
// that this is atomic, and using the database transaction hook on the backend (or commit/rollback
// hooks).
client.payments.makeIbanPayment(iban, 100),
] as const;
});