gre.add_data_listener

gre.add_data_listener(
    key,
    callback
)

Add a data change listener. When the specified variable changes in the data manager, the provided callback function will be executed.

Parameters:
        key            The data manager key used to listen for data changes
        callback       The callback function with parameters (key, value)
Return:
        An integer that identifies the created listener or nil on failure. The identifier is required to remove the listener.
Example:
        -- Register a data change listener:
        gre.add_data_listener("Layer.Control.grd_hidden", function(key, value)
            gre.log(gre.LOG_ALWAYS, "Key: %s, Value: %s", key, tostring(value))
        end)
Was this article helpful?
0 out of 0 found this helpful