diff --git a/doc/reference/reference_lua/box_events.rst b/doc/reference/reference_lua/box_events.rst index b6748bfb78..0dcadf7595 100644 --- a/doc/reference/reference_lua/box_events.rst +++ b/doc/reference/reference_lua/box_events.rst @@ -64,9 +64,12 @@ Below is a list of all functions and pages related to watchers or events. * - Name - Use - * - :doc:`./box_events/watch` + * - :ref:`box.watch() ` - Create a local watcher. + * - :ref:`box.watch_once() ` + - Get the current key value. + * - :ref:`conn:watch() ` - Create a watcher for the remote host. @@ -80,5 +83,6 @@ Below is a list of all functions and pages related to watchers or events. :hidden: box_events/watch + box_events/watch_once box_events/broadcast box_events/system_events \ No newline at end of file diff --git a/doc/reference/reference_lua/box_events/watch_once.rst b/doc/reference/reference_lua/box_events/watch_once.rst new file mode 100644 index 0000000000..361eb8cef2 --- /dev/null +++ b/doc/reference/reference_lua/box_events/watch_once.rst @@ -0,0 +1,37 @@ +.. _box-watch_once: + +box.watch_once() +================ + +.. function:: box.watch_once(key, func) + + Returns the current value of a given notification key. + The function can be used as an alternative to :ref:`box.watch() ` + when the caller only needs the current value without subscribing to future changes. + + :param string key: key name + + :return: the key value + + To read more about watchers, see the :ref:`box-watchers` section. + + **Example:** + + .. code-block:: lua + + -- Broadcast value 42 for the 'foo' key. + box.broadcast('foo', 42) + + -- Get the value of this key + tarantool> box.watch_once('foo') + --- + - 42 + ... + + -- Non-existent keys' values are empty + tarantool> box.watch_once('none') + --- + ... + + +