|
| 1 | +# react-call domain |
| 2 | + |
| 3 | +Glossary of the terms used across the library, its docs, and its agent |
| 4 | +skills. Terms here are project-specific; general programming concepts |
| 5 | +are excluded. |
| 6 | + |
| 7 | +## Language |
| 8 | + |
| 9 | +### Core |
| 10 | + |
| 11 | +**Callable**: |
| 12 | +The value returned by `createCallable()`. It is both a React component |
| 13 | +(mount it as `<Confirm />`) and a namespace of imperative methods |
| 14 | +(`call`, `upsert`, `end`, `update`). One Callable maps to one async UI |
| 15 | +pattern. |
| 16 | +_Avoid_: Modal, Dialog, Component (those are what a Callable models, not |
| 17 | +the thing itself). |
| 18 | + |
| 19 | +**Call**: |
| 20 | +A single imperative invocation of a Callable (`Confirm.call({...})`). |
| 21 | +Resolves to a `Response` once the call's `end` runs. The same Callable |
| 22 | +can have many concurrent calls. |
| 23 | +_Avoid_: Invocation, request, instance. |
| 24 | + |
| 25 | +**Root**: |
| 26 | +The mounting form of a Callable inside the React tree. Soft-deprecated |
| 27 | +alias `Callable.Root`; canonical form is the bare component |
| 28 | +(`<Confirm />`). See ADR-0013. |
| 29 | +_Avoid_: Provider, Portal, Outlet. |
| 30 | + |
| 31 | +**CallContext**: |
| 32 | +The `call` prop the user component receives per active call. Exposes |
| 33 | +`end`, `ended`, `key`, `index`, `stackSize`, `root`. Per-call; siblings |
| 34 | +in the stack each get their own. |
| 35 | +_Avoid_: Props.call, context (React `Context` is something else). |
| 36 | + |
| 37 | +**Stack**: |
| 38 | +The ordered list of currently-active calls of a Callable. The Root |
| 39 | +renders the stack; newer calls appear later in iteration order. |
| 40 | +_Avoid_: Queue, list, history. |
| 41 | + |
| 42 | +**Upsert**: |
| 43 | +Singleton-style call semantics. First `upsert()` creates the call, |
| 44 | +subsequent `upsert()`s update its props. Returns the same promise across |
| 45 | +the singleton's lifetime. |
| 46 | +_Avoid_: Toast, singleton (those are use cases, not the operation). |
| 47 | + |
| 48 | +**Caller scope**: |
| 49 | +The site where `Confirm.call({...})` is invoked β typically a feature |
| 50 | +component or a domain handler. The async logic and the response handling |
| 51 | +live here. |
| 52 | +_Avoid_: Parent, container. |
| 53 | + |
| 54 | +### Mutation flow |
| 55 | + |
| 56 | +**MutationFlow**: |
| 57 | +The orchestrated async-submission lifecycle: trigger fires β pending |
| 58 | +goes true β caller-supplied async runs β on success the caller closes |
| 59 | +the call, on throw the call stays open and pending clears. Provided by |
| 60 | +`useMutationFlow` from the subpath entry `react-call/mutation-flow`. |
| 61 | +_Avoid_: Submission, async pattern, mutation (bare). |
| 62 | + |
| 63 | +**MutationFn**: |
| 64 | +The async handler the caller provides as a prop of the call. Signature |
| 65 | +`(call, payload) => Promise<void>`. Owns the side effects and decides |
| 66 | +when to close the call. |
| 67 | +_Avoid_: Action, onSubmit, mutator, asyncAction. |
| 68 | + |
| 69 | +**MutationCall**: |
| 70 | +The minimal view of CallContext that a MutationFn receives β currently |
| 71 | +just `{ end }`. Narrower than CallContext on purpose, so MutationFn does |
| 72 | +not need to know `RootProps`. |
| 73 | +_Avoid_: MutationContext (would falsely suggest a separate React |
| 74 | +Context), Closer. |
| 75 | + |
| 76 | +**Trigger**: |
| 77 | +The callable function returned by `useMutationFlow`. Calling it runs the |
| 78 | +MutationFn (or the fallback) while exposing `trigger.pending`. One |
| 79 | +trigger per call to `useMutationFlow`. |
| 80 | +_Avoid_: Submit, runner, dispatcher. |
| 81 | + |
| 82 | +**Fallback response**: |
| 83 | +The Response value used when `submit()` fires but no MutationFn was |
| 84 | +provided. Required as the 3rd argument to `useMutationFlow` exactly when |
| 85 | +the MutationFn parameter is typed as possibly-undefined. |
| 86 | +_Avoid_: Default, no-op. |
| 87 | + |
| 88 | +## Relationships |
| 89 | + |
| 90 | +- A **Callable** produces zero or more **Calls** over its lifetime. |
| 91 | +- A **Call** carries one **CallContext**; siblings in the **Stack** each |
| 92 | + carry their own. |
| 93 | +- A **MutationFlow** is scoped to a single **Call** β the **Trigger** |
| 94 | + closes over that call's **CallContext**. |
| 95 | +- A **MutationFn** lives in **caller scope** but runs against the |
| 96 | + **MutationCall** view of the **CallContext**, not the full one. |
| 97 | +- The **Fallback response** is only meaningful when the **MutationFn** |
| 98 | + may be absent at the **Call** site. |
| 99 | + |
| 100 | +## Example dialogue |
| 101 | + |
| 102 | +> **Maintainer:** "If the **MutationFn** throws, does the **Call** end?" |
| 103 | +> |
| 104 | +> **Designer:** "No β the **Trigger** swallows the throw, **pending** |
| 105 | +> clears, the **Call** stays open. The **MutationFn** itself decides |
| 106 | +> when to invoke `call.end()`." |
| 107 | +> |
| 108 | +> **Maintainer:** "And if the caller never provides a **MutationFn**?" |
| 109 | +> |
| 110 | +> **Designer:** "Then `submit()` closes the **Call** with the |
| 111 | +> **Fallback response** β but the type signature only lets you omit the |
| 112 | +> fallback when the **MutationFn** parameter is non-nullable." |
| 113 | +
|
| 114 | +## Flagged ambiguities |
| 115 | + |
| 116 | +- "mutation" used to mean both the **MutationFlow** (the lifecycle) and |
| 117 | + the **MutationFn** (the handler). Resolved: **MutationFlow** is the |
| 118 | + pattern, **MutationFn** is the function the caller writes. |
| 119 | +- "context" risked collision with React's `Context`. Resolved: we use |
| 120 | + **CallContext** (the per-call prop bag, not a React `Context`) and |
| 121 | + **MutationCall** (the subset the handler sees) β the word "context" |
| 122 | + alone is avoided in lib API. |
| 123 | +- "asyncAction" appears in third-party patterns this design takes |
| 124 | + inspiration from. Resolved: the canonical name in react-call is |
| 125 | + **MutationFn**. |
0 commit comments