This function has been deprecated and should not be used in new work. You can use the
MessagingService|Cross Server Messaging Service to publish and subscribe to topics to receive near real-time updates, completely replacing the need for this function.
This function sets callback as the function to be run any time the value associated with the
GlobalDataStore|data store's key changes. Once every minute, OnUpdate polls for changes by other servers. Changes made on the same server will run the function immediately. In other words, functions like
GlobalDataStore/UpdateAsync|UpdateAsync() change the key’s value in the data store and will cause the function to run.
Articles/Data store|Data Stores article for an in-depth guide on data structure, management, error handling, etc.
The key identifying the entry being retrieved from the data store
The function to be executed any time the value associated with key is changed
The connection to the key being tracked for updates
Print Data Store Value on Update
The sample creates an
GlobalDataStore/OnUpdate|OnUpdate() connection with the key
myKey and the
printOut() function, then it sets the
myKey store to 11. Since the connection with
myKey is open,
printOut() executes and prints the input (the updated value). Immediately after this occurs, the script disconnects the connection.