hooks/useSaveLoad#
useSaveLoad()#
Hook for save/load functionality with entity browser integration
Type Parameters#
| Type Parameter | Default type |
|---|---|
TProtocol |
any |
Parameters#
| Parameter | Type |
|---|---|
config |
SaveLoadConfig<TProtocol> |
Returns#
Example#
const { pluginId, sendMessage } = usePluginContext()
const state = useSharedPluginState<MyState>()
const saveLoad = useSaveLoad({
pluginId,
sendMessage,
currentEntityName: state?.name
})
// Use with EntityBrowser
<EntityBrowser.Dialog
entityType={saveLoad.entityType}
onSelect={saveLoad.load}
/>
SaveLoadActions#
Properties#
entityType#
Entity type ID for use with EntityBrowser
list#
Get list of entities
Returns#
Promise<string[]>
load#
Load an entity
Parameters#
| Parameter | Type |
|---|---|
name |
string |
Returns#
Promise<void>
save#
Save current entity
Parameters#
| Parameter | Type |
|---|---|
name |
string |
Returns#
Promise<void>
SaveLoadConfig#
useSaveLoad Hook
Provides developer-friendly save/load functionality for plugins. Automatically handles: - Entity browser registration - Save/Load dialogs - Backend communication
Extended by#
Type Parameters#
| Type Parameter | Default type |
|---|---|
TProtocol |
any |
Properties#
currentEntityName?#
Current entity name (for highlighting in entity browser)
entityTypeSuffix?#
Custom entity type suffix (default: 'entities')
methods?#
optional methods?: {
list?: keyof TProtocol;
load?: keyof TProtocol;
preview?: keyof TProtocol;
save?: keyof TProtocol;
};
Backend method names - type-safe against protocol interface
list?#
load?#
preview?#
save?#
previewComponent?#
Optional custom preview component