Skip to content

Commit 2a6d7ea

Browse files
StCyrsusnux
authored andcommitted
Adds an example how to emi files:node:* events
Signed-off-by: Cyrille Bollu <[email protected]>
1 parent 9fb405f commit 2a6d7ea

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

developer_manual/client_apis/files.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ the ``event-bus`` and use the following events:
3030
* ``files:node:moved``: the node has been moved (and its data is already updated)
3131
* ``files:node:updated``: the node data has been updated
3232

33-
Example
33+
All these events use a Node as argument.
34+
35+
Examples
3436
-------
3537

3638
.. code-block:: ts
@@ -42,6 +44,20 @@ Example
4244
console.log('Node created', node)
4345
})
4446
47+
.. code-block:: ts
48+
49+
import { davGetClient, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
50+
import { emit } from '@nextcloud/event-bus'
51+
52+
const client = davGetClient()
53+
client.stat(`${davRootPath}${filename}`, {
54+
details: true,
55+
data: davGetDefaultPropfind(),
56+
}).then((result) => {
57+
const node = davResultToNode(result.data)
58+
emit('files:node:updated', node)
59+
})
60+
4561
4662
Router
4763
^^^^^^

0 commit comments

Comments
 (0)