Concorde decorator — @patch. Sends the value of a publisher as the body of a PATCH request, to update part of a resource, and stores the response in an ApiResult<T> property. It takes the same arguments, options and send(componen Doc ID: docs/decorators/patch. Keywords: Concorde, supersoniks, docs/decorators/patch, patch, @patch, decorator, PATCH, ApiResult, send(component), send, endpoint, Endpoint, bodyKey, DataProviderKey, configurationKey. URL: https://concorde.supersoniks.org/docs/decorators/patch.
@patch
Sends the value of a publisher as the body of a PATCH request, to update part of a resource, and stores the response in an ApiResult<T> property. It takes the same arguments, options and send(component) handle as @post; only the HTTP method differs.
Import
import { patch, type ApiResult } from "@supersoniks/concorde/decorators";
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
Basic usage
The body holds only the fields to change, here a gate change for flight CN 001.
type Flight = { flight: string; route: string; gate: string };
const gateChangeKey = new DataProviderKey<Partial<Flight>>("gateChange");
@patch(new Endpoint<Flight>("flights/CN001"), gateChangeKey)
@state()
payload?: ApiResult<Flight>;
moveToB12() {
set(gateChangeKey, { gate: "B12" }); // sends the PATCH
}
Triggers, the send method decorator and every option are described on @post.
API reference
| Argument | Type | Description |
|---|---|---|
endpoint |
Endpoint<T> |
Resource path and response type |
bodyKey |
DataProviderKey<B> |
Publisher read as the partial body |
configurationKey |
DataProviderKey<APIConfiguration> (optional) |
API configuration publisher. Default: HTML scope |
options |
PatchOptions |
Same as @post options |