From 2a6d7ea96db5c53baebc1acdb206cf08490d8799 Mon Sep 17 00:00:00 2001 From: Cyrille Bollu Date: Sun, 30 Jun 2024 21:32:18 +0200 Subject: [PATCH] Adds an example how to emi files:node:* events Signed-off-by: Cyrille Bollu --- developer_manual/client_apis/files.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/developer_manual/client_apis/files.rst b/developer_manual/client_apis/files.rst index e02451b02..9d42585bf 100644 --- a/developer_manual/client_apis/files.rst +++ b/developer_manual/client_apis/files.rst @@ -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 ^^^^^^