File tree 2 files changed +42
-1
lines changed
doc/reference/reference_lua
2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -64,9 +64,12 @@ Below is a list of all functions and pages related to watchers or events.
64
64
* - Name
65
65
- Use
66
66
67
- * - :doc: ` ./box_events/ watch `
67
+ * - :ref: ` box. watch() < box-watch > `
68
68
- Create a local watcher.
69
69
70
+ * - :ref: `box.watch_once() <box-watch >`
71
+ - Get the current key value.
72
+
70
73
* - :ref: `conn:watch() <conn-watch >`
71
74
- Create a watcher for the remote host.
72
75
@@ -80,5 +83,6 @@ Below is a list of all functions and pages related to watchers or events.
80
83
:hidden:
81
84
82
85
box_events/watch
86
+ box_events/watch_once
83
87
box_events/broadcast
84
88
box_events/system_events
Original file line number Diff line number Diff line change
1
+ .. _box-watch_once :
2
+
3
+ box.watch_once()
4
+ ================
5
+
6
+ .. function :: box.watch_once(key, func)
7
+
8
+ Returns the current value of a given notification key.
9
+ The function can be used as an alternative to :ref: `box.watch() <box-watch >`
10
+ when the caller only needs the current value without subscribing to future changes.
11
+
12
+ :param string key: key name
13
+
14
+ :return: the key value
15
+
16
+ To read more about watchers, see the :ref: `box-watchers ` section.
17
+
18
+ **Example: **
19
+
20
+ .. code-block :: lua
21
+
22
+ -- Broadcast value 42 for the 'foo' key.
23
+ box.broadcast('foo', 42)
24
+
25
+ -- Get the value of this key
26
+ tarantool> box.watch_once('foo')
27
+ ---
28
+ - 42
29
+ ...
30
+
31
+ -- Non-existent keys' values are empty
32
+ tarantool> box.watch_once('none')
33
+ ---
34
+ ...
35
+
36
+
37
+
You can’t perform that action at this time.
0 commit comments