From 7e89809ee17bbd6555180a8e29d1f89b84c7fc3f Mon Sep 17 00:00:00 2001 From: ClockworkSquirrel Date: Thu, 3 Sep 2020 20:26:25 +0100 Subject: [PATCH] Update docs to reflect changes by @boatbomber Merged in changes by @boatbomber; updated docs to reflect these awesome new additions. --- docs/docs.md | 23 ++++++++++++++++++++++- docs/index.md | 3 +++ src/init.lua | 5 ++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 64d96ee..b7223cc 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -99,7 +99,7 @@ BuyItem("Noodles", 12) ## `State:RawSet()` ----- -Sets a value in the store without firing any `.Changed` (or `:GetChangedSignal`) events. +Sets a value in the store without firing any `.Changed` (or `:GetChangedSignal`) events. `:RawSet()` will also ignore the value of `ProtectType`, so be careful when dealing with type-sensitive data. ### Syntax `State:RawSet(Key: any, Value: any): void` @@ -194,3 +194,24 @@ end) State:Set("Hello", "Roblox") ``` + +## `State.ProtectType` +----- +A boolean value which determines whether strict type-checking is enabled on the state table. This prevents changing the type of stored data, e.g. from a number to a string. This is **disabled** by default. + +To enable type-safety, simply set this property to true after initialising a new BasicState instance: `State.ProtectType = true`. + +Using `:RawSet()` will ignore type-checking. + +### Syntax +`State.ProtectType: boolean` + +### Example +```lua +local State = BasicState.new({ + Hello = "World" +}) + +State.ProtectType = true +State:Set("Hello", 1234) --> Will throw an error: A string was expected, but it received a number. +``` diff --git a/docs/index.md b/docs/index.md index e82dbb3..1bde72f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,9 @@ # BasicState BasicState is a really, really simple key-value based state management solution. It makes use of [BindableEvents](https://developer.roblox.com/en-us/api-reference/class/BindableEvent) to allow your projects to watch for changes in state, and provides a simple API for communication with your state objects. Think [Rodux](https://roblox.github.io/rodux/), but much more simple. +## Community +Special thanks to the contributors of this project! You've made some great improvements and added some awesome features. 😁 + ## Getting Started It's easy to get started using BasicState. There are a few methods to add BasicState to your project: diff --git a/src/init.lua b/src/init.lua index df9a850..0671ac2 100644 --- a/src/init.lua +++ b/src/init.lua @@ -1,6 +1,9 @@ --[[ BasicState by csqrl (ClockworkSquirrel) - Version: 0.1.1 + Version: 0.2.0 + + Other Contributors: + https://github.com/ClockworkSquirrel/BasicState/graphs/contributors Documentation is at: https://clockworksquirrel.github.io/BasicState/