Concorde decorator — @put. @put replaces a resource with the body from a publisher. It uses exactly the Doc ID: docs/_decorators/put. Keywords: Concorde, supersoniks, docs/_decorators/put, put, @put, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
, when: "before", autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing. URL: https://concorde.supersoniks.org/crawl/docs/_decorators/put.html.
@put
@put replaces a resource with the body from a publisher. It uses exactly the
same model as @post:
Endpoint<T>, DataProviderKey<B>, ApiResult<T>, options, and the
send(component) handle.
Minimal usage
const bodyKey = new DataProviderKey<UpdateUser>("users.form");
const updateUser = put(new Endpoint<User>("users/42"), bodyKey);
@updateUser
@state()
payload?: ApiResult<User>;
The same decorator adapts to a method:
@put(new Endpoint<User>("users/42"), bodyKey)
handleUpdate(payload?: ApiResult<User>) {
if (payload?.response?.ok) console.log(payload.result);
}
To run the operation again from the component:
async update() {
await updateUser.send(this);
}
send(component) returns a Promise resolved after the PUT completes. See
@post for the method-decorator form and the
when: "before" option.
The PUT is also sent automatically when the body mutates, unless
autoPostOnBodyMutation: false is set. See
@post for the option details:
autoPostOnBodyMutationskipIfBodyMissingrefetchEveryMsskipEmptyPlaceholdertriggerKey
Pass explicit API configuration as the third argument:
@put(endpoint, bodyKey, apiConfigurationKey)
Import
import { put, type ApiResult } from "@supersoniks/concorde/decorators";
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
See also
- @post — options and triggers
- @patch — partial update
- Dynamic path placeholders