A destination change keeps prior-operation correlation
Changing the destination clears its source rows and prevents late acknowledgements from changing the new import. A bounded notice preserves operation IDs that the original service may need to reconcile.
Keyboard
- Switch the destination while Apply is waiting, then inspect the retained operation ID.
- The new import starts with no previous rows. Completing the old callback does not advance its phase.
States covered
- source boundary
- in-flight cancellation
- late acknowledgement
- bounded operation IDs
- no cross-destination retry
Install this complete example and its component dependencies.
npx shadcn@latest add https://ui.bld8.dev/r/example-import-source-boundary.jsonComplete source
/*!
MIT License
Copyright (c) 2026 Jaison
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useRef,useState} from 'react';
import {Button,ImportWizard,UIProvider,type ImportField,type ImportRequest,type ImportApplyResult} from '@bld8/ui';
const fields:ImportField[]=[{key:'id',label:'ID',type:'text',required:true},{key:'name',label:'Name',type:'text',required:true}];
export default function ImportBoundary(){const [destination,setDestination]=useState(1),[last,setLast]=useState('none'),pending=useRef<{request:ImportRequest;resolve:(result:ImportApplyResult)=>void}[]>([]);
async function apply(request:ImportRequest):Promise<ImportApplyResult>{setLast(request.requestId);return new Promise(resolve=>{pending.current.push({request,resolve});});}
return <UIProvider><div style={{display:'grid',gap:20}}><div style={{display:'flex',gap:12,flexWrap:'wrap'}}><Button variant="secondary" onClick={()=>setDestination(value=>value+1)}>Switch import destination</Button><Button variant="ghost" onClick={()=>{const first=pending.current.shift();if(first)first.resolve({ok:true,requestId:first.request.requestId,count:first.request.rows.length});}}>Complete previous callback</Button></div>
<p>Destination {destination}</p><ImportWizard label="Destination import" fields={fields} identityField="id" sourceKey={String(destination)} onApply={apply}/><p data-boundary-request style={{overflowWrap:'anywhere'}}>Last request: {last}</p><p className="bui-hint">A deferred local callback demonstrates client isolation. It does not store records. Reconcile real operation IDs with the service that received them.</p></div></UIProvider>;}