| Tarantool
Документация на русском языке
поддерживается сообществом, func)

Subscribe to events broadcast by a local host.

  • key (string) – key name of the event to subscribe to
  • func (function) – callback to invoke when the key value is updated

a watcher handle. The handle consists of one method – unregister(), which unregisters the watcher.

To read more about watchers, see the Functions for watchers section.


Keep in mind that garbage collection of a watcher handle doesn’t lead to the watcher’s destruction. In this case, the watcher remains registered. It is okay to discard the result of watch function if the watcher will never be unregistered.


-- Broadcast value 42 for the 'foo' key.
box.broadcast('foo', 42)

local log = require('log')
-- Subscribe to updates of the 'foo' key.
local w ='foo', function(key, value)
    assert(key == 'foo')"The value is '%d'", value)

If you don’t need the watcher anymore, you can unregister it using the command below:

Нашли ответ на свой вопрос?
Обратная связь