{"id":"ocipa/accord","name":"accord","scope":"ocipa","platform":"roblox","description":"https://github.com/Ocipa/accord","version":"0.13.1","latest":"0.13.1","versions":["0.5.3","0.5.4","0.9.0","0.11.0","0.12.0","0.13.0","0.13.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"bcb6c38ab48a22c2a26b944f849e57f1c5b5cc393372868a1f339d93dcecf471","likes":0,"downloads":0,"install":"forest install ocipa/accord","url":"https://forest.dev/p/roblox/ocipa/accord","files":"https://api.forest.dev/ai/package/roblox/ocipa/accord/files","readme":"<h1 align=\"center\">accord</h1>\r\n<div align=\"center\">⚠️Repo is in development, EVERYTHING is subject to change⚠️</div>\r\n<br>\r\n\r\n```lua\r\nlocal accord = require(accord)\r\n\r\naccord:NewState(\"balance\", 0)\r\n\r\nfunction accord.balance:Inc(num: number)\r\n    self.value += num\r\nend\r\n\r\nfunction accord.balance:Dec(num: number)\r\n    self.value -= num\r\nend\r\n\r\nprint(accord.balance:GetValue()) -- 0\r\n\r\naccord.balance:Inc(8)\r\nprint(accord.balance:GetValue()) -- 8\r\n\r\naccord.balance:Dec(6)\r\nprint(accord.balance:GetValue()) -- 2\r\n```\r\n\r\n## API\r\n\r\n`Accord`\r\n```lua\r\nAccord:NewState(stateName: string, defaultValue: any, config: Config?): State\r\n-- Creates a new state.\r\n```\r\n```lua\r\nAccord:GetState(stateName: string): State\r\n-- Gets the state.\r\n```\r\n```lua\r\nAccord:Connect(callback: (stateName: string, value: any?): nil): signal.ScriptConnection\r\n-- Connects a callback to when any state value changes.\r\n```\r\n```lua\r\nAccord:ConnectOnce(callback: (stateName: string, value: any?): nil): nil\r\n-- Connects a callback to when any state value changes once.\r\n```\r\n```lua\r\nAccord:DisconnectAll(): nil\r\n-- Disconnects all connections to accord.\r\n```\r\n```lua\r\nAccord:DestroyState(stateName: string): nil\r\n-- Destroys a state, disconnecting the connections and removing the value.\r\n```\r\n```lua\r\nAccord:DestroyAll(): nil\r\n-- Destroys all states, disconnecting the connections and removing the values.\r\n```\r\n\r\n`State`\r\n```lua\r\nState:GetValue(): any?\r\n-- Gets the value of the state.\r\n```\r\n```lua\r\nState:GetLastValue(): any?\r\n-- Gets the last value of the state.\r\n```\r\n```lua\r\nState:RelativeRescind(num: number): nil\r\n-- Rescinds the value of the state. If the num is negative, goes back in the\r\n-- value history, if num is positive, goes forward in value history, if nil,\r\n-- goes to the last history (the most recent value change).\r\n```\r\n```lua\r\nState:Connect(callback: (value: any?): nil): signal.ScriptConnection\r\n-- Connects a callback to when the state value changes.\r\n```\r\n```lua\r\nState:ConnectOnce(callback: (value: any?): nil): nil\r\n-- Connects a callback to when the state value changes once.\r\n```\r\n```lua\r\nState:DisconnectAll(): nil\r\n-- Disconnects all connections to the state.\r\n```\r\n```lua\r\nState:Destroy(): nil\r\n-- Destroys the state, disconnecting the connections and removing the value.\r\n```\r\n\r\n\r\n\r\n\r\n\r\n## Examples\r\n\r\n```lua\r\nlocal accord = require(path to accord)\r\n\r\naccord:NewState(\"TestState\", 0)\r\n\r\nfunction accord.TestState:TestMethod(number: number)\r\n    self.value += number\r\nend\r\n\r\naccord.TestState:Connect(function(value)\r\n    print((\"changed TestState from %s, to %s\"):format(accord.TestState:GetLastValue(), value))\r\nend)\r\n\r\naccord.TestState:TestMethod(4)\r\n-- prints \"changed TestState from 0, to 4\"\r\n\r\naccord.TestState:TestMethod(7)\r\n-- prints \"changed TestState from 4, to 11\"\r\n```\r\n\r\n```lua\r\n-- script1\r\nlocal accord = require(path to accord)\r\n\r\naccord:NewState(\"SomeState\", \"Hello\")\r\n\r\nfunction accord.SomeState:Concat(other: string)\r\n    self.value = self.value .. other\r\nend\r\n\r\naccord.SomeState:ConnectOnce(function(value)\r\n    print((\"%s\"):format(value))\r\nend)\r\n\r\n\r\n\r\n-- script2\r\nlocal accord = require(path to accord)\r\n\r\ntask.delay(1, function()\r\n    accord.SomeState:Concat(\" World!\")\r\n    -- prints \"Hello World!\"\r\n\r\n    accord.SomeState:Concat(\" Again!\")\r\n    -- does not print since ConnectOnce was used\r\nend)\r\n```\r\n\r\n## License\r\n\r\nDistributed under the MIT License. See [LICENSE](./LICENSE) for more information.","readmeBorrowedFrom":{"version":"0.9.0","source":"wally"},"readmeTruncated":false}