From 8658e1fd807e6a6b5a0119a1c51314ebc89f22d0 Mon Sep 17 00:00:00 2001
From: quackbox <49273992+quackbox@users.noreply.github.com>
Date: Wed, 14 Aug 2019 15:39:44 +0930
Subject: [PATCH] implement SaveAsync() and updated documentation (#42)
* implement SaveAsync() and updated documentation
* fixed re-use of :Save() code, now calls :Save()
---
DataStore2/init.lua | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/DataStore2/init.lua b/DataStore2/init.lua
index 29b5332..0d0764f 100644
--- a/DataStore2/init.lua
+++ b/DataStore2/init.lua
@@ -12,6 +12,7 @@
- BeforeInitialGet(modifier)
- BeforeSave(modifier)
- Save()
+ - SaveAsync()
- OnUpdate(callback)
- BindToClose(callback)
@@ -405,6 +406,15 @@ function DataStore:Save()
end
end
+--[[**
+
+ Asynchronously saves the data to the data store.
+
+**--]]
+function DataStore:SaveAsync()
+ coroutine.wrap(DataStore.Save)(self)
+end
+
--[[**
Add a function to be called before the game closes. Fired with the player and value of the data store.