I havenāt used this library or looked into it, so I donāt know itās API, but public set tells me you should probably be assigning to the OnUpdate key.
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.