@supersoniks/concorde 4.9.91 → 4.9.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +156 -156
- package/concorde-core.es.js +2348 -2331
- package/dist/concorde-core.bundle.js +156 -156
- package/dist/concorde-core.es.js +2348 -2331
- package/dist/js/core/decorators/api.js +64 -51
- package/dist/js/core/decorators/api.js.map +1 -1
- package/dist/types/core/decorators/api.d.ts +10 -5
- package/dist/types/core/decorators/api.d.ts.map +1 -1
- package/docs/assets/{index-BL6WVF7g.css → index-D2Q3JyQ6.css} +1 -1
- package/docs/assets/{index-DVn8AeyA.js → index-DURr6O71.js} +466 -568
- package/docs/crawl/docs/_decorators/get.html +35 -10
- package/docs/crawl/docs/_decorators/patch.html +13 -5
- package/docs/crawl/docs/_decorators/post.html +39 -10
- package/docs/crawl/docs/_decorators/put.html +13 -5
- package/docs/crawl/hubs/decorators.html +43 -40
- package/docs/crawl/hubs/remote-data.html +43 -40
- package/docs/index.html +2 -2
- package/docs/llms-full.txt +98 -23
- package/docs/llms.txt +1 -1
- package/docs/src/docs/_decorators/get.md +39 -5
- package/docs/src/docs/_decorators/patch.md +8 -3
- package/docs/src/docs/_decorators/post.md +39 -6
- package/docs/src/docs/_decorators/put.md +8 -3
- package/docs/src/docs/search/docs-search.json +103 -183
- package/docs/src/tsconfig.json +268 -268
- package/package.json +1 -1
- package/src/core/decorators/api.post.spec.ts +2 -2
- package/src/core/decorators/api.spec.ts +47 -6
- package/src/core/decorators/api.ts +100 -64
- package/src/docs/_decorators/get.md +12 -5
- package/src/docs/_decorators/patch.md +7 -2
- package/src/docs/_decorators/post.md +12 -7
- package/src/docs/_decorators/put.md +7 -2
- package/src/docs/components/docs-demo-sources.ts +8 -8
- package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +2 -2
- package/src/docs/search/docs-search.json +2 -2
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>@get — Concorde</title>
|
|
7
|
-
<meta name="description" content="@get loads data and stores the result in an ApiResult<T>
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult
|
|
7
|
+
<meta name="description" content="@get loads data and stores the result in an optional ApiResult<T> property.">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult, undefined, payload.result, payload.response, payload.request,
|
|
9
9
|
|
|
10
10
|
The first argument is always an
|
|
11
11
|
[, serviceURL, refetch(component),
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
">
|
|
14
14
|
<meta name="concorde-doc-id" content="docs/_decorators/get">
|
|
15
15
|
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/get.html">
|
|
16
16
|
</head>
|
|
@@ -20,14 +20,15 @@ The first argument is always an
|
|
|
20
20
|
</header>
|
|
21
21
|
<main>
|
|
22
22
|
<article>
|
|
23
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @get</strong>. @get loads data and stores the result in an ApiResult<T>
|
|
23
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @get</strong>. @get loads data and stores the result in an optional ApiResult<T> property. <span>Doc ID: <code>docs/_decorators/get</code>. Keywords: Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult, undefined, payload.result, payload.response, payload.request,
|
|
24
24
|
|
|
25
25
|
The first argument is always an
|
|
26
26
|
[, serviceURL, refetch(component),
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/get.html">https://concorde.supersoniks.org/crawl/docs/_decorators/get.html</a>.</span></p>
|
|
29
29
|
<h1 id="get">@get</h1>
|
|
30
|
-
<p><code>@get</code> loads data and stores the result in an <code>ApiResult<T>
|
|
30
|
+
<p><code>@get</code> loads data and stores the result in an optional <code>ApiResult<T></code> property.
|
|
31
|
+
The property is <code>undefined</code> until a result is available.</p>
|
|
31
32
|
<ul>
|
|
32
33
|
<li><code>payload.result</code>: typed data;</li>
|
|
33
34
|
<li><code>payload.response</code>: the HTTP response;</li>
|
|
@@ -38,7 +39,7 @@ The first argument is always an
|
|
|
38
39
|
|
|
39
40
|
@get(usersEndpoint)
|
|
40
41
|
@state()
|
|
41
|
-
payload
|
|
42
|
+
payload?: ApiResult<User[]>;
|
|
42
43
|
</code></pre>
|
|
43
44
|
<p>The first argument is always an
|
|
44
45
|
<a href="../_misc/endpoint.html#endpoint"><code>Endpoint<T></code></a>. API configuration is read
|
|
@@ -53,12 +54,34 @@ result.</p>
|
|
|
53
54
|
|
|
54
55
|
@usersGet
|
|
55
56
|
@state()
|
|
56
|
-
payload
|
|
57
|
+
payload?: ApiResult<User[]>;
|
|
57
58
|
|
|
58
|
-
refresh() {
|
|
59
|
-
usersGet.refetch(this);
|
|
59
|
+
async refresh() {
|
|
60
|
+
const payload = await usersGet.refetch(this);
|
|
61
|
+
console.log(payload?.result);
|
|
60
62
|
}
|
|
61
63
|
</code></pre>
|
|
64
|
+
<p><code>refetch(component)</code> returns a <code>Promise<ApiResult<T> | undefined></code> that resolves
|
|
65
|
+
after the GET has completed.</p>
|
|
66
|
+
<h3 id="from-a-method-decorator">From a method decorator</h3>
|
|
67
|
+
<p>The refetch can decorate a local method. The default is <code>after</code>; if the
|
|
68
|
+
method returns a Promise, the GET waits for its resolution. The decorated method
|
|
69
|
+
call also waits for the refetch to complete.</p>
|
|
70
|
+
<pre><code class="language-typescript">import { refetch } from "@supersoniks/concorde/decorators";
|
|
71
|
+
|
|
72
|
+
@refetch(usersGet)
|
|
73
|
+
async reload() {
|
|
74
|
+
this.userId = "42";
|
|
75
|
+
}
|
|
76
|
+
</code></pre>
|
|
77
|
+
<p>Use <code>{ when: "before" }</code> when the GET must complete before the method runs:</p>
|
|
78
|
+
<pre><code class="language-typescript">@refetch(usersGet, { when: "before" })
|
|
79
|
+
reloadBefore() {
|
|
80
|
+
// The refetch has completed before this method runs.
|
|
81
|
+
}
|
|
82
|
+
</code></pre>
|
|
83
|
+
<p>The method decorator adds an explicit trigger; changes to dynamic endpoint
|
|
84
|
+
properties and configuration publishers keep their existing automatic behavior.</p>
|
|
62
85
|
<h2 id="options-getoptions">Options (<code>GetOptions</code>)</h2>
|
|
63
86
|
<p>Options are the second argument, or the third argument when an API
|
|
64
87
|
configuration key is provided.</p>
|
|
@@ -66,6 +89,7 @@ configuration key is provided.</p>
|
|
|
66
89
|
<li><code>skipEmptyPlaceholder</code>: blocks the GET when <code>${prop}</code> is <code>""</code>.</li>
|
|
67
90
|
<li><code>refetchEveryMs</code>: automatically runs the GET again after this interval
|
|
68
91
|
(milliseconds). Omit the option, or use <code>0</code>, to disable polling.</li>
|
|
92
|
+
<li><code>triggerKey</code>: a publisher whose <code>invalidate()</code> runs the GET again.</li>
|
|
69
93
|
</ul>
|
|
70
94
|
<p>With a configuration key, use:</p>
|
|
71
95
|
<pre><code class="language-typescript">@get(usersEndpoint, apiConfigurationKey)
|
|
@@ -75,6 +99,7 @@ configuration key is provided.</p>
|
|
|
75
99
|
<li>when the component connects and configuration is available;</li>
|
|
76
100
|
<li>when a property used in <code>${...}</code> changes;</li>
|
|
77
101
|
<li>when a configuration publisher changes;</li>
|
|
102
|
+
<li>when the <code>triggerKey</code> publisher is invalidated;</li>
|
|
78
103
|
<li>after each response when <code>refetchEveryMs</code> is set.</li>
|
|
79
104
|
</ul>
|
|
80
105
|
<p>See <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a> for
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>@patch — Concorde</title>
|
|
7
7
|
<meta name="description" content="@patch applies a partial update with the body from a publisher. It uses the">
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
9
|
+
|
|
10
|
+
, when: "before", autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing">
|
|
9
11
|
<meta name="concorde-doc-id" content="docs/_decorators/patch">
|
|
10
12
|
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html">
|
|
11
13
|
</head>
|
|
@@ -15,7 +17,9 @@
|
|
|
15
17
|
</header>
|
|
16
18
|
<main>
|
|
17
19
|
<article>
|
|
18
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @patch</strong>. @patch applies a partial update with the body from a publisher. It uses the <span>Doc ID: <code>docs/_decorators/patch</code>. Keywords: Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
20
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @patch</strong>. @patch applies a partial update with the body from a publisher. It uses the <span>Doc ID: <code>docs/_decorators/patch</code>. Keywords: Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
21
|
+
|
|
22
|
+
, when: "before", autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html">https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html</a>.</span></p>
|
|
19
23
|
<h1 id="patch">@patch</h1>
|
|
20
24
|
<p><code>@patch</code> applies a partial update with the body from a publisher. It uses the
|
|
21
25
|
same model as <a href="./post.html#post">@post</a>:
|
|
@@ -27,13 +31,16 @@ const patchUser = patch(new Endpoint<User>("users/42"), bodyKey)
|
|
|
27
31
|
|
|
28
32
|
@patchUser
|
|
29
33
|
@state()
|
|
30
|
-
payload
|
|
34
|
+
payload?: ApiResult<User>;
|
|
31
35
|
</code></pre>
|
|
32
36
|
<p>To run the operation again from the component:</p>
|
|
33
|
-
<pre><code class="language-typescript">savePatch() {
|
|
34
|
-
patchUser.send(this);
|
|
37
|
+
<pre><code class="language-typescript">async savePatch() {
|
|
38
|
+
await patchUser.send(this);
|
|
35
39
|
}
|
|
36
40
|
</code></pre>
|
|
41
|
+
<p><code>send(component)</code> returns a Promise resolved after the PATCH completes. See
|
|
42
|
+
<a href="./post.html#post">@post</a> for the method-decorator form and the
|
|
43
|
+
<code>when: "before"</code> option.</p>
|
|
37
44
|
<p>The PATCH is also sent automatically when the body mutates, unless
|
|
38
45
|
<code>autoPostOnBodyMutation: false</code> is set. The available options are described in
|
|
39
46
|
<a href="./post.html#post">@post</a>:</p>
|
|
@@ -42,6 +49,7 @@ payload: ApiResult<User> | null = null;
|
|
|
42
49
|
<li><code>skipIfBodyMissing</code></li>
|
|
43
50
|
<li><code>refetchEveryMs</code></li>
|
|
44
51
|
<li><code>skipEmptyPlaceholder</code></li>
|
|
52
|
+
<li><code>triggerKey</code></li>
|
|
45
53
|
</ul>
|
|
46
54
|
<p>Pass explicit API configuration as the third argument:</p>
|
|
47
55
|
<pre><code class="language-typescript">@patch(endpoint, bodyKey, apiConfigurationKey)
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>@post — Concorde</title>
|
|
7
7
|
<meta name="description" content="@post sends the contents of a publisher and stores the response in an">
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, ApiResult
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, ApiResult, undefined, Endpoint, DataProviderKey,
|
|
9
9
|
|
|
10
10
|
The current body is read from , send(component),
|
|
11
11
|
|
|
12
|
-
,
|
|
12
|
+
, returns a ,
|
|
13
|
+
|
|
14
|
+
Use ">
|
|
13
15
|
<meta name="concorde-doc-id" content="docs/_decorators/post">
|
|
14
16
|
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/post.html">
|
|
15
17
|
</head>
|
|
@@ -19,14 +21,17 @@ The current body is read from , send(component),
|
|
|
19
21
|
</header>
|
|
20
22
|
<main>
|
|
21
23
|
<article>
|
|
22
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @post</strong>. @post sends the contents of a publisher and stores the response in an <span>Doc ID: <code>docs/_decorators/post</code>. Keywords: Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, ApiResult
|
|
24
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @post</strong>. @post sends the contents of a publisher and stores the response in an <span>Doc ID: <code>docs/_decorators/post</code>. Keywords: Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, ApiResult, undefined, Endpoint, DataProviderKey,
|
|
23
25
|
|
|
24
26
|
The current body is read from , send(component),
|
|
25
27
|
|
|
26
|
-
,
|
|
28
|
+
, returns a ,
|
|
29
|
+
|
|
30
|
+
Use . URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/post.html">https://concorde.supersoniks.org/crawl/docs/_decorators/post.html</a>.</span></p>
|
|
27
31
|
<h1 id="post">@post</h1>
|
|
28
32
|
<p><code>@post</code> sends the contents of a publisher and stores the response in an
|
|
29
|
-
<code>ApiResult<T>
|
|
33
|
+
optional <code>ApiResult<T></code> property. The property is <code>undefined</code> until a result
|
|
34
|
+
is available.</p>
|
|
30
35
|
<h2 id="minimal-usage">Minimal usage</h2>
|
|
31
36
|
<p>Pass an <code>Endpoint<T></code> and a <code>DataProviderKey<B></code> for the request body.</p>
|
|
32
37
|
<pre><code class="language-typescript">const userBodyKey = new DataProviderKey<CreateUser>("users.form");
|
|
@@ -34,7 +39,7 @@ const createUser = post(new Endpoint<User>("users"), userBodyKey
|
|
|
34
39
|
|
|
35
40
|
@createUser
|
|
36
41
|
@state()
|
|
37
|
-
payload
|
|
42
|
+
payload?: ApiResult<User>;
|
|
38
43
|
</code></pre>
|
|
39
44
|
<p>The current body is read from <code>userBodyKey</code>. By default, the POST is sent when
|
|
40
45
|
the component connects and after each body mutation. Mutations in the same
|
|
@@ -45,12 +50,34 @@ frame are coalesced into one request.</p>
|
|
|
45
50
|
<h3 id="from-the-component">From the component</h3>
|
|
46
51
|
<p>Keep the decorator to access <code>send(component)</code>. The body is read again when the
|
|
47
52
|
operation runs.</p>
|
|
48
|
-
<pre><code class="language-typescript">saveAgain() {
|
|
49
|
-
createUser.send(this);
|
|
53
|
+
<pre><code class="language-typescript">async saveAgain() {
|
|
54
|
+
const payload = await createUser.send(this);
|
|
55
|
+
console.log(payload?.result);
|
|
56
|
+
}
|
|
57
|
+
</code></pre>
|
|
58
|
+
<p><code>send()</code> returns a <code>Promise<ApiResult<T> | undefined></code> that resolves after the
|
|
59
|
+
operation completes. It is useful for “Save” or “Retry” buttons and can repeat
|
|
60
|
+
an operation with side effects.</p>
|
|
61
|
+
<h3 id="from-a-method-decorator">From a method decorator</h3>
|
|
62
|
+
<p>The send action can decorate a local method. It runs after the method by
|
|
63
|
+
default, waits for an eventual Promise to resolve, and the decorated method
|
|
64
|
+
call waits for the send to complete:</p>
|
|
65
|
+
<pre><code class="language-typescript">import { send } from "@supersoniks/concorde/decorators";
|
|
66
|
+
|
|
67
|
+
@send(createUser)
|
|
68
|
+
async save() {
|
|
69
|
+
// Prepare local state or validate the form.
|
|
70
|
+
}
|
|
71
|
+
</code></pre>
|
|
72
|
+
<p>Use <code>{ when: "before" }</code> when the send must complete before the method runs:</p>
|
|
73
|
+
<pre><code class="language-typescript">@send(createUser, { when: "before" })
|
|
74
|
+
saveBefore() {
|
|
75
|
+
// The POST has completed before this method runs.
|
|
50
76
|
}
|
|
51
77
|
</code></pre>
|
|
52
|
-
<p
|
|
53
|
-
|
|
78
|
+
<p>The method decorator adds an explicit send. If the method also mutates the body
|
|
79
|
+
publisher, set <code>autoPostOnBodyMutation: false</code> when the decorated method must
|
|
80
|
+
be the only trigger.</p>
|
|
54
81
|
<h2 id="options-postoptions">Options (<code>PostOptions</code>)</h2>
|
|
55
82
|
<p>Options are the third argument, or the fourth argument when a configuration key
|
|
56
83
|
is provided.</p>
|
|
@@ -63,6 +90,7 @@ it to <code>false</code> to use <code>send()</code>.</li>
|
|
|
63
90
|
repeating the operation is intended.</li>
|
|
64
91
|
<li><code>skipEmptyPlaceholder</code>: block the request when a <code>${...}</code> placeholder is
|
|
65
92
|
<code>""</code>.</li>
|
|
93
|
+
<li><code>triggerKey</code>: a publisher whose <code>invalidate()</code> sends the POST again.</li>
|
|
66
94
|
</ul>
|
|
67
95
|
<p>With a configuration key:</p>
|
|
68
96
|
<pre><code class="language-typescript">@post(endpoint, userBodyKey, apiConfigurationKey)
|
|
@@ -75,6 +103,7 @@ dynamic path details.</p>
|
|
|
75
103
|
<li>after a body mutation, unless <code>autoPostOnBodyMutation: false</code>;</li>
|
|
76
104
|
<li>when a property used in <code>${...}</code> changes;</li>
|
|
77
105
|
<li>when a configuration publisher changes;</li>
|
|
106
|
+
<li>when the <code>triggerKey</code> publisher is invalidated;</li>
|
|
78
107
|
<li>when <code>send()</code> is called;</li>
|
|
79
108
|
<li>after each response when <code>refetchEveryMs</code> is set.</li>
|
|
80
109
|
</ul>
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>@put — Concorde</title>
|
|
7
7
|
<meta name="description" content="@put replaces a resource with the body from a publisher. It uses exactly the">
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/put, put, @put, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/put, put, @put, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
9
|
+
|
|
10
|
+
, when: "before", autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing">
|
|
9
11
|
<meta name="concorde-doc-id" content="docs/_decorators/put">
|
|
10
12
|
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/put.html">
|
|
11
13
|
</head>
|
|
@@ -15,7 +17,9 @@
|
|
|
15
17
|
</header>
|
|
16
18
|
<main>
|
|
17
19
|
<article>
|
|
18
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @put</strong>. @put replaces a resource with the body from a publisher. It uses exactly the <span>Doc ID: <code>docs/_decorators/put</code>. Keywords: Concorde, supersoniks, docs/_decorators/put, put, @put, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
20
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @put</strong>. @put replaces a resource with the body from a publisher. It uses exactly the <span>Doc ID: <code>docs/_decorators/put</code>. Keywords: Concorde, supersoniks, docs/_decorators/put, put, @put, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
|
|
21
|
+
|
|
22
|
+
, when: "before", autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/put.html">https://concorde.supersoniks.org/crawl/docs/_decorators/put.html</a>.</span></p>
|
|
19
23
|
<h1 id="put">@put</h1>
|
|
20
24
|
<p><code>@put</code> replaces a resource with the body from a publisher. It uses exactly the
|
|
21
25
|
same model as <a href="./post.html#post">@post</a>:
|
|
@@ -27,13 +31,16 @@ const updateUser = put(new Endpoint<User>("users/42"), bodyKey);
|
|
|
27
31
|
|
|
28
32
|
@updateUser
|
|
29
33
|
@state()
|
|
30
|
-
payload
|
|
34
|
+
payload?: ApiResult<User>;
|
|
31
35
|
</code></pre>
|
|
32
36
|
<p>To run the operation again from the component:</p>
|
|
33
|
-
<pre><code class="language-typescript">update() {
|
|
34
|
-
updateUser.send(this);
|
|
37
|
+
<pre><code class="language-typescript">async update() {
|
|
38
|
+
await updateUser.send(this);
|
|
35
39
|
}
|
|
36
40
|
</code></pre>
|
|
41
|
+
<p><code>send(component)</code> returns a Promise resolved after the PUT completes. See
|
|
42
|
+
<a href="./post.html#post">@post</a> for the method-decorator form and the
|
|
43
|
+
<code>when: "before"</code> option.</p>
|
|
37
44
|
<p>The PUT is also sent automatically when the body mutates, unless
|
|
38
45
|
<code>autoPostOnBodyMutation: false</code> is set. See
|
|
39
46
|
<a href="./post.html#post">@post</a> for the option details:</p>
|
|
@@ -42,6 +49,7 @@ payload: ApiResult<User> | null = null;
|
|
|
42
49
|
<li><code>skipIfBodyMissing</code></li>
|
|
43
50
|
<li><code>refetchEveryMs</code></li>
|
|
44
51
|
<li><code>skipEmptyPlaceholder</code></li>
|
|
52
|
+
<li><code>triggerKey</code></li>
|
|
45
53
|
</ul>
|
|
46
54
|
<p>Pass explicit API configuration as the third argument:</p>
|
|
47
55
|
<pre><code class="language-typescript">@put(endpoint, bodyKey, apiConfigurationKey)
|
|
@@ -149,10 +149,11 @@ export class DemoBind extends LitElement {
|
|
|
149
149
|
<section id="docs-_decorators-get" data-doc-id="docs/_decorators/get">
|
|
150
150
|
<h2><a href="../docs/_decorators/get.html">@get</a></h2>
|
|
151
151
|
<p><strong>Doc ID:</strong> <code>docs/_decorators/get</code> · <a href="../docs/_decorators/get.html">full page</a></p>
|
|
152
|
-
<p>@get loads data and stores the result in an ApiResult<T>
|
|
152
|
+
<p>@get loads data and stores the result in an optional ApiResult<T> property.</p>
|
|
153
153
|
<pre class="doc-excerpt">@get
|
|
154
154
|
|
|
155
|
-
@get loads data and stores the result in an ApiResult
|
|
155
|
+
@get loads data and stores the result in an optional ApiResult property.
|
|
156
|
+
The property is undefined until a result is available.
|
|
156
157
|
|
|
157
158
|
- payload.result: typed data;
|
|
158
159
|
- payload.response: the HTTP response;
|
|
@@ -164,7 +165,7 @@ const usersEndpoint = new Endpoint ("users");
|
|
|
164
165
|
|
|
165
166
|
@get(usersEndpoint)
|
|
166
167
|
@state()
|
|
167
|
-
payload
|
|
168
|
+
payload?: ApiResult ;
|
|
168
169
|
|
|
169
170
|
The first argument is always an
|
|
170
171
|
Endpoint . API configuration is read
|
|
@@ -183,22 +184,20 @@ const usersGet = get(new Endpoint ("users"));
|
|
|
183
184
|
|
|
184
185
|
@usersGet
|
|
185
186
|
@state()
|
|
186
|
-
payload
|
|
187
|
+
payload?: ApiResult ;
|
|
187
188
|
|
|
188
|
-
refresh() {
|
|
189
|
-
usersGet.refetch(this);
|
|
189
|
+
async refresh() {
|
|
190
|
+
const payload = await usersGet.refetch(this);
|
|
191
|
+
console.log(payload?.result);
|
|
190
192
|
}
|
|
191
193
|
|
|
192
|
-
|
|
194
|
+
refetch(component) returns a Promise | undefined> that resolves
|
|
195
|
+
after the GET has completed.
|
|
193
196
|
|
|
194
|
-
|
|
195
|
-
configuration key is provided.
|
|
197
|
+
From a method decorator
|
|
196
198
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(milliseconds). Omit the option, or use 0, to disable polling.
|
|
200
|
-
|
|
201
|
-
With a configurat</pre>
|
|
199
|
+
The refetch can decorate a local method. The default is after; if the
|
|
200
|
+
method returns a Promise, the GET waits for its resol</pre>
|
|
202
201
|
</section>
|
|
203
202
|
<section id="docs-_decorators-handle" data-doc-id="docs/_decorators/handle">
|
|
204
203
|
<h2><a href="../docs/_decorators/handle.html">@handle</a></h2>
|
|
@@ -293,14 +292,18 @@ const patchUser = patch(new Endpoint ("users/42"), bodyKey);
|
|
|
293
292
|
|
|
294
293
|
@patchUser
|
|
295
294
|
@state()
|
|
296
|
-
payload
|
|
295
|
+
payload?: ApiResult ;
|
|
297
296
|
|
|
298
297
|
To run the operation again from the component:
|
|
299
298
|
|
|
300
|
-
savePatch() {
|
|
301
|
-
patchUser.send(this);
|
|
299
|
+
async savePatch() {
|
|
300
|
+
await patchUser.send(this);
|
|
302
301
|
}
|
|
303
302
|
|
|
303
|
+
send(component) returns a Promise resolved after the PATCH completes. See
|
|
304
|
+
@post for the method-decorator form and the
|
|
305
|
+
when: "before" option.
|
|
306
|
+
|
|
304
307
|
The PATCH is also sent automatically when the body mutates, unless
|
|
305
308
|
autoPostOnBodyMutation: false is set. The available options are described in
|
|
306
309
|
@post:
|
|
@@ -309,6 +312,7 @@ autoPostOnBodyMutation: false is set. The available options are described in
|
|
|
309
312
|
- skipIfBodyMissing
|
|
310
313
|
- refetchEveryMs
|
|
311
314
|
- skipEmptyPlaceholder
|
|
315
|
+
- triggerKey
|
|
312
316
|
|
|
313
317
|
Pass explicit API configuration as the third argument:
|
|
314
318
|
|
|
@@ -322,9 +326,7 @@ import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
|
322
326
|
|
|
323
327
|
See also
|
|
324
328
|
|
|
325
|
-
- @post
|
|
326
|
-
- @put — full replacement
|
|
327
|
-
- Dynamic path placeholders</pre>
|
|
329
|
+
- @post —</pre>
|
|
328
330
|
</section>
|
|
329
331
|
<section id="docs-_decorators-post" data-doc-id="docs/_decorators/post">
|
|
330
332
|
<h2><a href="../docs/_decorators/post.html">@post</a></h2>
|
|
@@ -333,7 +335,8 @@ See also
|
|
|
333
335
|
<pre class="doc-excerpt">@post
|
|
334
336
|
|
|
335
337
|
@post sends the contents of a publisher and stores the response in an
|
|
336
|
-
ApiResult
|
|
338
|
+
optional ApiResult property. The property is undefined until a result
|
|
339
|
+
is available.
|
|
337
340
|
|
|
338
341
|
Minimal usage
|
|
339
342
|
|
|
@@ -344,7 +347,7 @@ const createUser = post(new Endpoint ("users"), userBodyKey);
|
|
|
344
347
|
|
|
345
348
|
@createUser
|
|
346
349
|
@state()
|
|
347
|
-
payload
|
|
350
|
+
payload?: ApiResult ;
|
|
348
351
|
|
|
349
352
|
The current body is read from userBodyKey. By default, the POST is sent when
|
|
350
353
|
the component connects and after each body mutation. Mutations in the same
|
|
@@ -360,23 +363,19 @@ From the component
|
|
|
360
363
|
Keep the decorator to access send(component). The body is read again when the
|
|
361
364
|
operation runs.
|
|
362
365
|
|
|
363
|
-
saveAgain() {
|
|
364
|
-
createUser.send(this);
|
|
366
|
+
async saveAgain() {
|
|
367
|
+
const payload = await createUser.send(this);
|
|
368
|
+
console.log(payload?.result);
|
|
365
369
|
}
|
|
366
370
|
|
|
367
|
-
send()
|
|
368
|
-
|
|
371
|
+
send() returns a Promise | undefined> that resolves after the
|
|
372
|
+
operation completes. It is useful for “Save” or “Retry” buttons and can repeat
|
|
373
|
+
an operation with side effects.
|
|
369
374
|
|
|
370
|
-
|
|
375
|
+
From a method decorator
|
|
371
376
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
- autoPostOnBodyMutation: send after a body mutation (default: true). Set
|
|
376
|
-
it to false to use send().
|
|
377
|
-
- skipIfBodyMissing: skip when the body is null or undefined (default:
|
|
378
|
-
true).
|
|
379
|
-
- refetchE</pre>
|
|
377
|
+
The send action can decorate a local method. It runs after the method by
|
|
378
|
+
default, waits for an eventu</pre>
|
|
380
379
|
</section>
|
|
381
380
|
<section id="docs-_decorators-publish" data-doc-id="docs/_decorators/publish">
|
|
382
381
|
<h2><a href="../docs/_decorators/publish.html">@publish</a></h2>
|
|
@@ -439,14 +438,18 @@ const updateUser = put(new Endpoint ("users/42"), bodyKey);
|
|
|
439
438
|
|
|
440
439
|
@updateUser
|
|
441
440
|
@state()
|
|
442
|
-
payload
|
|
441
|
+
payload?: ApiResult ;
|
|
443
442
|
|
|
444
443
|
To run the operation again from the component:
|
|
445
444
|
|
|
446
|
-
update() {
|
|
447
|
-
updateUser.send(this);
|
|
445
|
+
async update() {
|
|
446
|
+
await updateUser.send(this);
|
|
448
447
|
}
|
|
449
448
|
|
|
449
|
+
send(component) returns a Promise resolved after the PUT completes. See
|
|
450
|
+
@post for the method-decorator form and the
|
|
451
|
+
when: "before" option.
|
|
452
|
+
|
|
450
453
|
The PUT is also sent automatically when the body mutates, unless
|
|
451
454
|
autoPostOnBodyMutation: false is set. See
|
|
452
455
|
@post for the option details:
|
|
@@ -455,6 +458,7 @@ autoPostOnBodyMutation: false is set. See
|
|
|
455
458
|
- skipIfBodyMissing
|
|
456
459
|
- refetchEveryMs
|
|
457
460
|
- skipEmptyPlaceholder
|
|
461
|
+
- triggerKey
|
|
458
462
|
|
|
459
463
|
Pass explicit API configuration as the third argument:
|
|
460
464
|
|
|
@@ -469,8 +473,7 @@ import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
|
469
473
|
See also
|
|
470
474
|
|
|
471
475
|
- @post — options and triggers
|
|
472
|
-
-
|
|
473
|
-
- Dynamic path placeholders</pre>
|
|
476
|
+
- @</pre>
|
|
474
477
|
</section>
|
|
475
478
|
<section id="docs-_decorators-subscribe" data-doc-id="docs/_decorators/subscribe">
|
|
476
479
|
<h2><a href="../docs/_decorators/subscribe.html">@subscribe</a></h2>
|