Wow! Really cool! It would be really useful for me in discord js, you could just update a value in DataStores with just running a command. Cool feature!
As I said, I don’t know the API of this library, having never used it or looked at the code.
Purely based on the screenshot you shared, I’d say the OnUpdate function is called whenever the DataStore you connected to previously is updated.
The OnUpdate property of the DataStore should be assigned a callback function, which takes three parameters: Key, OldValue and NewValue.
What you choose to do with those values once you receive them is up to you. For example, if you wanted to watch for changes in the “LordMerc” key, your callback function might look like this:
if (key === "LordMerc") {
console.dir("LordMerc key was updated:", oldValue, newValue)
}
Obviously I am not the best person to ask about this library, but hopefully I’ve deduced it correctly from the screenshot, and hopefully @0x6e7367 (or someone else with experience with the library) will be able to give you a more accurate and correct answer.
Aye, I appreciate the help. I just saw that he included coverage of OnUpdate, albeit I know it’s deprecated and not really trustworthy. Wanted to see if that’s the same case even using it outside of roblox.
I just had a quick look at the source, and it appears the OnUpdate function is currently unimplemented; however, I would imagine it’d poll the DataStore endpoint automatically for you once implemented, and run the callback function you specify, as detailed above.
So OnUpdate is a callback to be invoked on UpdateAsync sucess only (As I am only invoking it in .then, I will have one for .catch); it is deprecated but I plan to improve it’s performance, it has a private get, because you don’t need the callback.
@RakNetProtocol How would I, for example, show a leaderboard VIA discord using this. An example:
let DataStoreService = RDS.DataStoreService;
let DataStore = DataStoreService.GetOrderedDataStore('LBS', 'global');
let Data = DataStore.GetSortedAsync(false, 10)
let Data_Pages = Data.GetCurrentPage() --It errors right here saying its not a function.