File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -254,6 +254,31 @@ When the `waitForActionAttempt` option is enabled, the SDK:
254254- Rejects with a ` SeamActionAttemptTimeoutError ` if the action attempt is still pending when the ` timeout ` is reached.
255255- Both errors expose an ` actionAttempt ` property.
256256
257+ The ` ActionAttempt ` type is a union discriminated by ` action_type ` and ` status ` .
258+ The ` error ` and ` result ` properties are typed as ` null `
259+ except for the status that populates them,
260+ so narrow on the ` status ` before reading them:
261+
262+ ``` ts
263+ const actionAttempt = await seam .locks .unlockDoor (
264+ { device_id },
265+ { waitForActionAttempt: false },
266+ )
267+
268+ if (actionAttempt .status === ' success' ) {
269+ console .log (actionAttempt .result ) // The result is non-null here.
270+ }
271+
272+ if (actionAttempt .status === ' error' ) {
273+ console .log (actionAttempt .error .message ) // The error is non-null here.
274+ }
275+ ```
276+
277+ Waiting for an action attempt resolves with the successful action attempt,
278+ so after checking ` status === 'success' ` the ` result ` is immediately usable.
279+ Use the ` SucceededActionAttempt ` and ` FailedActionAttempt ` types
280+ to extract the success and error members from any action attempt type.
281+
257282If you already have an action attempt ID
258283and want to wait for it to resolve, simply use
259284
You can’t perform that action at this time.
0 commit comments