{"id":"csqrl/basicstate","name":"basicstate","scope":"csqrl","platform":"roblox","description":"Really simple state management","version":"0.2.6","latest":"0.2.6","versions":["0.2.3","0.2.4","0.2.5","0.2.6"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"484c37ea621b8c9d1ad10c2ebc90ca57d2f9ff20305a40a92ad4090b4476d877","likes":0,"downloads":0,"install":"forest install csqrl/basicstate","url":"https://forest.dev/p/roblox/csqrl/basicstate","files":"https://api.forest.dev/ai/package/roblox/csqrl/basicstate/files","readme":"<!-- Project Link References -->\n\n[ci status]: https://github.com/csqrl/BasicState/actions\n[latest release]: https://github.com/csqrl/BasicState/releases/latest\n[library url]: https://www.roblox.com/library/5023525481\n[docs]: https://csqrl.github.io/BasicState\n[npm package]: https://www.npmjs.com/package/@rbxts/basicstate\n[ts bindings repo]: https://github.com/tech0tron/BasicState\n\n<!-- Articles -->\n\n[rojo]: https://rojo.space\n[wally]: https://github.com/upliftgames/wally\n[roblox/rodux]: https://roblox.github.io/rodux/\n[devhub/bindableevents]: https://developer.roblox.com/en-us/api-reference/class/BindableEvent\n[roblox-ts]: https://roblox-ts.com/\n[@tech0tron]: https://github.com/tech0tron\n\n<!-- Images -->\n\n[shield ci]: https://github.com/csqrl/BasicState/actions/workflows/unit-tests.yml/badge.svg\n[shield gh release]: https://img.shields.io/github/v/release/csqrl/BasicState?label=latest+release&style=flat\n[shield wally release]: https://img.shields.io/endpoint?url=https://runkit.io/clockworksquirrel/wally-version-shield/branches/master/csqrl/BasicState&color=blue&label=wally&style=flat\n[hero]: .github/assets/basicstate-cover.png\n\n[![BasicState][hero]][docs]\n\n[![CI][shield ci]][ci status]\n[![GitHub release (latest by date)][shield gh release]][latest release]\n[![Wally release (latest)][shield wally release]][latest release]\n\nBasicState is a really simple key-value based state management solution. It makes use of [BindableEvents][devhub/bindableevents] to allow your project to watch for changes in state, and provides a simple but comprehensive API for communication with your state objects. Think [Rodux][roblox/rodux], but easier!\n\n## Installation\n\n### [Rojo][rojo]\n\nYou can use git submodules to clone this repo into your project's packages directory:\n\n```sh\n$ git submodule add https://github.com/csqrl/BasicState packages/BasicState\n```\n\nOnce added, simply sync into Studio using the [Rojo][rojo] plugin.\n\n#### 0.5.x\n\nDownload/clone this repo on to your device, and copy the `/src` directory into your packages directory.\n\n### [Wally][wally]\n\nAdd `BasicState` to your `wally.toml` and run `wally install`\n\n```toml\n[package]\nname = \"user/repo\"\ndescription = \"My awesome Roblox project\"\nversion = \"1.0.0\"\nlicense = \"MIT\"\nauthors = [\"You (https://github.com/you)\"]\nregistry = \"https://github.com/UpliftGames/wally-index\"\nrealm = \"shared\"\n\n[dependencies]\nBasicState = \"csqrl/BasicState@^0.2.6\"\n```\n\n```sh\n$ wally install\n```\n\n### [Roblox-TS][roblox-ts] (unofficial)\n\nWhile this package doesn't officially support TypeScript, bindings are available under the [`@rbxts/basicstate`][npm package] package, which can be installed using npm or yarn.\n\n```sh\n$ npm i @rbxts/basicstate\n$ yarn add @rbxts/basicstate\n$ pnpm add @rbxts/basicstate\n```\n\nTypeScript bindings are provided by [@tech0tron][@tech0tron]. Please file any issues for the npm package over on [their repo][ts bindings repo].\n\n### Manual Installation\n\nGrab a copy [from the Roblox Library (Toolbox)][library url], or download the latest `.rbxm/.rbxmx` file from [the releases page][latest release] and drop it into Studio.\n\n## Usage\n\nHere's a quick example of how BasicState can be used:\n\n```lua\nlocal BasicState = require(path.to.BasicState)\n\nlocal State = BasicState.new({\n    Hello = \"World\"\n})\n\nState:GetChangedSignal(\"Hello\"):Connect(function(NewValue, OldValue)\n    print(string.format(\"Hello, %s; goodbye %s!\", NewValue, OldValue))\nend)\n\nState:SetState({\n    Hello = \"Roblox\"\n})\n\n--[[\n    Triggers the RBXScriptConnection above and prints\n    \"Hello, Roblox; goodbye World!\"\n--]]\n```\n\nUsage with Roact:\n\n```lua\n-- Store.lua\nlocal BasicState = require(path.to.BasicState)\n\nlocal Store = BasicState.new({\n    Hello = \"World\"\n})\n\nreturn Store\n```\n\n```lua\n-- MyComponent.lua\nlocal Roact = require(path.to.Roact)\nlocal MyComponent = Roact.Component:extend(\"MyComponent\")\n\nlocal Store = require(script.Parent.Parent.Store)\n\nfunction MyComponent:render()\n    return Roact.createElement(\"TextButton\", {\n        Text = string.format(\"Hello, %s!\", self.state.Hello),\n        --> Displays \"Hello, World!\"\n\n        [Roact.Event.MouseButton1Click] = function()\n            Store:SetState({ Hello = \"Roblox\" })\n            --> Will re-render and display \"Hello, Roblox!\"\n        end\n    })\nend\n\n-- Wrap the component with the BasicState store\nreturn Store:Roact(MyComponent)\n```\n\n# Documentation\n\nPlease [refer to the documentation site][docs] for a full overview of the exported API and further examples on how to use this module.\n","readmeTruncated":false}