This plugin allows you to store your data inside the local
or session
storage using the orchy's eventBus
.
The plugin accepts one attribute:
strategy
: it is used to configure the storage kind for your data. Actually onlylocal
andsession
are supported.
The plugin accepts one property:
eventBus
: theorchy's eventBus
instance.
Note that the eventBus
property will be automatically injected by orchy
.
{
"type": "element",
"tag": "orchy-storage-plugin",
"url": "//localhost:3000/orchy-storage-plugin.js",
"attributes": {
"strategy": "local", // or "session"
}
}
<script type="module" src="//localhost:3000/orchy-storage-plugin.js"></script>
<orchy-storage-plugin orchy-element strategy="local"></orchy-storage-plugin>
To retrieve your data, you should send a message following this format:
{
label: 'orchy-storage:get',
payload: {
key: any;
}
}
The label has been defined as a constant in the OrchyStorageEventsLabels.GET
module.
We suggest to use the orchyStorageEventsBuilder.get
function to create this structure.
If your data is correctly retrieved, you will receive a message with the following format:
{
label: 'orchy-storage:get:result',
payload: {
key: any;
value: any;
}
}
The label has been defined as a constant in the OrchyStorageEventsLabels.GET_RESULT
module.
To insert your data, you should send a message following this format:
{
label: 'orchy-storage:post',
payload: {
key: any;
value: any;
}
}
The label has been defined as a constant in the OrchyStorageEventsLabels.POST
module.
We suggest to use the orchyStorageEventsBuilder.post
function to create this structure.
To delete your data, you should send a message following this format:
{
label: 'orchy-storage:delete',
payload: {
key: any;
}
}
The label has been defined as a constant in the OrchyStorageEventsLabels.DELETE
module.
We suggest to use the orchyStorageEventsBuilder.delete
function to create this structure.
To clear all data, you should send a message following this format:
{
label: 'orchy-storage:clear',
}
The label has been defined as a constant in the OrchyStorageEventsLabels.CLEAR
module.
We suggest to use the orchyStorageEventsBuilder.clear
function to create this structure.