Adds an example how to emi files:node:* events

Signed-off-by: Cyrille Bollu <StCyr@users.noreply.github.com>
This commit is contained in:
Cyrille Bollu
2024-06-30 21:32:18 +02:00
committed by Ferdinand Thiessen
parent 9fb405f5b7
commit 2a6d7ea96d

View File

@@ -30,7 +30,9 @@ the ``event-bus`` and use the following events:
* ``files:node:moved``: the node has been moved (and its data is already updated)
* ``files:node:updated``: the node data has been updated
Example
All these events use a Node as argument.
Examples
-------
.. code-block:: ts
@@ -42,6 +44,20 @@ Example
console.log('Node created', node)
})
.. code-block:: ts
import { davGetClient, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
import { emit } from '@nextcloud/event-bus'
const client = davGetClient()
client.stat(`${davRootPath}${filename}`, {
details: true,
data: davGetDefaultPropfind(),
}).then((result) => {
const node = davResultToNode(result.data)
emit('files:node:updated', node)
})
Router
^^^^^^