An interface describing how to retrieve and manage persistently stored resources.
Resources are JSON documents stored in a persistent manner (and synced accross devices if using the Sync add on).
MindDrop's core is responsible for retrieving and managing persistent resources. Resource types can be registered using the core.registerResource
method. See the Core API page for more details.
Property | Type | Description |
---|---|---|
type* | string | A unique identifier for the type of the resource composed using the extension ID and resource type: [extensionId]:[resourceType] . For example, topics have a type of 'topics:topic' . |
onLoad | ResourceLoadHandler | A callback fired once when the resources are loaded on app startup. See below for details. |
onChange | ResourceChangeHandler | A callback fired whenever a resource matching the given type is added, updated, or deleted. See below for details. |
createEvent | string | If provided, an event listener will be added for this event type. When such an event is fired, the attached resource will be added to the persistent store. The event data must be the resource itself. |
updateEvent | string | If provided, an event listener will be added for this event type. When such an event is fired, the attached resource will be updated in the persistent store. The event data must be a ResourceChange (see below for details). |
deleteEvent | string | If provided, an event listener will be added for this event type. When such an event is fired, the attached resource will be permanently deleted from the persistent store. The event data must be the resource itself. |
A callback fired once when the resources are loaded on app startup.
onLoad(core: Core, resources: Resouce[]): void;
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
resources* | [Resource] | The resources which were loaded from the persistent store. |
A callback fired whenever a resource matching the given type is added, updated, or deleted.
onChange(core: Core, resource: Resouce, deleted: boolean): void;
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
resource* | [Resource] | The resource which changed. |
deleted* | boolean | If true , the resource has been permanently deleted. |
Property | Type | Description |
---|---|---|
before | [Resource] | The resource data before it was changed. |
after | [Resource] | The resource data after it was changed. |
changes | [ResourceChanges] | The changes applied to the resource data. Supports FieldValue values. |