{"id":"iamthebestts/lux","name":"lux","scope":"iamthebestts","platform":"roblox","description":"Lightweight global state management for Luau","version":"0.1.0","latest":"0.1.0","versions":["0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"9775c0b9f07cf859d39c72114f75e52f821ebe9ad262fbca63ead37c74adc166","likes":0,"downloads":0,"install":"forest install iamthebestts/lux","url":"https://forest.dev/p/roblox/iamthebestts/lux","files":"https://api.forest.dev/ai/package/roblox/iamthebestts/lux/files","readme":"# lux\r\n\r\n[![ci](https://github.com/iamthebestts/lux/actions/workflows/ci.yml/badge.svg)](https://github.com/iamthebestts/lux/actions/workflows/ci.yml)\r\n[![Get it on Creator Store](./.github/assets/link-creator-store.svg)](https://create.roblox.com/store/asset/94035002056316/lux)\r\n[![Wally](./.github/assets/link-wally.svg)](https://wally.run/package/iamthebestts/lux)\r\n[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)\r\n\r\nLightweight reactive global state for Roblox.\r\n\r\n---\r\n\r\n## Overview\r\n\r\n`lux` is a small in-memory state registry for a single Roblox context.\r\n\r\nIt gives you:\r\n\r\n- keyed state lookup\r\n- subscriptions\r\n- derived state\r\n- explicit lifecycle control for computed values\r\n\r\nServer and client registries are separate.\r\n\r\n---\r\n\r\n## Install\r\n\r\n```toml\r\n[dependencies]\r\nlux = \"iamthebestts/lux@0.1.0\"\r\n````\r\n\r\n---\r\n\r\n## API\r\n\r\n### `lux.create`\r\n\r\n```luau\r\nlux.create(key: string, initialValue: T): State<T>\r\n```\r\n\r\nCreates a state under `key`.\r\n\r\n### `lux.find`\r\n\r\n```luau\r\nlux.find(key: string): State<unknown>?\r\n```\r\n\r\nReturns the state for `key`, or `nil`.\r\n\r\n### `lux.has`\r\n\r\n```luau\r\nlux.has(key: string): boolean\r\n```\r\n\r\nChecks whether `key` exists.\r\n\r\n### `lux.getAll`\r\n\r\n```luau\r\nlux.getAll(): { [string]: State<unknown> }\r\n```\r\n\r\nReturns a shallow copy of the registry.\r\n\r\n### `lux.computed`\r\n\r\n```luau\r\nlux.computed(deps: { Dep }, selector: ({ unknown }) -> T): ComputedState<T>\r\n```\r\n\r\nCreates a derived state.\r\n\r\n---\r\n\r\n## State\r\n\r\n### `:get`\r\n\r\n```luau\r\nstate:get(): T\r\n```\r\n\r\n### `:set`\r\n\r\n```luau\r\nstate:set(value: T): ()\r\n```\r\n\r\nSkips dispatch when `value == currentValue`.\r\n\r\n### `:subscribe`\r\n\r\n```luau\r\nstate:subscribe(callback: (T) -> ()): () -> ()\r\n```\r\n\r\nReturns an unsubscribe function.\r\n\r\n### `:once`\r\n\r\n```luau\r\nstate:once(callback: (T) -> ()): () -> ()\r\n```\r\n\r\nFires once, then unsubscribes.\r\n\r\n---\r\n\r\n## ComputedState\r\n\r\n`ComputedState` exposes:\r\n\r\n- `:get()`\r\n- `:subscribe()`\r\n- `:once()`\r\n- `:destroy()`\r\n\r\n`destroy()` removes dependency subscriptions and stops future updates.\r\n\r\n---\r\n\r\n## Contributing\r\n\r\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\r\n\r\n---\r\n\r\n## License\r\n\r\nThis project is licensed under the terms of the [MIT License](LICENSE)\r\n","readmeTruncated":false}