{"id":"eldonwilliams/basicstate","name":"basicstate","scope":"eldonwilliams","platform":"roblox","description":"BasicState without DevDeps to--hopefully--allow installation.","version":"0.2.4","latest":"0.2.4","versions":["0.2.3","0.2.4"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"7809bee114d5b9a8c621f65bcd5b9d3aa789145a33009d8fe3782bd0b04ba122","likes":0,"downloads":0,"install":"forest install eldonwilliams/basicstate","url":"https://forest.dev/p/roblox/eldonwilliams/basicstate","files":"https://api.forest.dev/ai/package/roblox/eldonwilliams/basicstate/files","readme":"# Terse edition\r\nTo get support for wally, this project removes all testing and dev-dependencies so that wally can work.\r\n\r\n<!-- Project Link References -->\r\n\r\n[ci status]: https://github.com/csqrl/BasicState/actions\r\n[latest release]: https://github.com/csqrl/BasicState/releases/latest\r\n[library url]: https://www.roblox.com/library/5023525481\r\n[docs]: https://csqrl.github.io/BasicState\r\n[npm package]: https://www.npmjs.com/package/@rbxts/basicstate\r\n[ts bindings repo]: https://github.com/tech0tron/BasicState\r\n\r\n<!-- Articles -->\r\n\r\n[rojo]: https://rojo.space\r\n[wally]: https://github.com/upliftgames/wally\r\n[roblox/rodux]: https://roblox.github.io/rodux/\r\n[devhub/bindableevents]: https://developer.roblox.com/en-us/api-reference/class/BindableEvent\r\n[roblox-ts]: https://roblox-ts.com/\r\n[@tech0tron]: https://github.com/tech0tron\r\n\r\n<!-- Images -->\r\n\r\n[shield ci]: https://github.com/csqrl/BasicState/actions/workflows/unit-tests.yml/badge.svg\r\n[shield gh release]: https://img.shields.io/github/v/release/csqrl/BasicState?label=latest+release&style=flat\r\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\r\n[hero]: .github/assets/basicstate-cover.png\r\n\r\n[![BasicState][hero]][docs]\r\n\r\n[![CI][shield ci]][ci status]\r\n[![GitHub release (latest by date)][shield gh release]][latest release]\r\n[![Wally release (latest)][shield wally release]][latest release]\r\n\r\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!\r\n\r\n## Installation\r\n\r\n### [Rojo][rojo]\r\n\r\nYou can use git submodules to clone this repo into your project's packages directory:\r\n\r\n```sh\r\n$ git submodule add https://github.com/csqrl/BasicState packages/BasicState\r\n```\r\n\r\nOnce added, simply sync into Studio using the [Rojo][rojo] plugin.\r\n\r\n#### 0.5.x\r\n\r\nDownload/clone this repo on to your device, and copy the `/src` directory into your packages directory.\r\n\r\n### [Wally][wally]\r\n\r\nAdd `BasicState` to your `wally.toml` and run `wally install`\r\n\r\n```toml\r\n[package]\r\nname = \"user/repo\"\r\ndescription = \"My awesome Roblox project\"\r\nversion = \"1.0.0\"\r\nlicense = \"MIT\"\r\nauthors = [\"You (https://github.com/you)\"]\r\nregistry = \"https://github.com/UpliftGames/wally-index\"\r\nrealm = \"shared\"\r\n\r\n[dependencies]\r\nBasicState = \"csqrl/BasicState@^0.2.3\"\r\n```\r\n\r\n```sh\r\n$ wally install\r\n```\r\n\r\n### [Roblox-TS][roblox-ts] (unofficial)\r\n\r\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.\r\n\r\n```sh\r\n$ npm i @rbxts/basicstate\r\n$ yarn add @rbxts/basicstate\r\n$ pnpm add @rbxts/basicstate\r\n```\r\n\r\nTypeScript bindings are provided by [@tech0tron][@tech0tron]. Please file any issues for the npm package over on [their repo][ts bindings repo].\r\n\r\n### Manual Installation\r\n\r\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.\r\n\r\n## Usage\r\n\r\nHere's a quick example of how BasicState can be used:\r\n\r\n```lua\r\nlocal BasicState = require(path.to.BasicState)\r\n\r\nlocal State = BasicState.new({\r\n    Hello = \"World\"\r\n})\r\n\r\nState:GetChangedSignal(\"Hello\"):Connect(function(NewValue, OldValue)\r\n    print(string.format(\"Hello, %s; goodbye %s!\", NewValue, OldValue))\r\nend)\r\n\r\nState:SetState({\r\n    Hello = \"Roblox\"\r\n})\r\n\r\n--[[\r\n    Triggers the RBXScriptConnection above and prints\r\n    \"Hello, Roblox; goodbye World!\"\r\n--]]\r\n```\r\n\r\nUsage with Roact:\r\n\r\n```lua\r\n-- Store.lua\r\nlocal BasicState = require(path.to.BasicState)\r\n\r\nlocal Store = BasicState.new({\r\n    Hello = \"World\"\r\n})\r\n\r\nreturn Store\r\n```\r\n\r\n```lua\r\n-- MyComponent.lua\r\nlocal Roact = require(path.to.Roact)\r\nlocal MyComponent = Roact.Component:extend(\"MyComponent\")\r\n\r\nlocal Store = require(script.Parent.Parent.Store)\r\n\r\nfunction MyComponent:render()\r\n    return Roact.createElement(\"TextButton\", {\r\n        Text = string.format(\"Hello, %s!\", self.state.Hello),\r\n        --> Displays \"Hello, World!\"\r\n\r\n        [Roact.Event.MouseButton1Click] = function()\r\n            Store:SetState({ Hello = \"Roblox\" })\r\n            --> Will re-render and display \"Hello, Roblox!\"\r\n        end\r\n    })\r\nend\r\n\r\n-- Wrap the component with the BasicState store\r\nreturn Store:Roact(MyComponent)\r\n```\r\n\r\n# Documentation\r\n\r\nPlease [refer to the documentation site][docs] for a full overview of the exported API and further examples on how to use this module.\r\n","readmeTruncated":false}