Forest Logo
search
package_2

rotai

By @piquu

Roblox

Mirrored from Wally

This version ships no README. Showing the README from v0.1.4, mirrored from wally.

Rotai

A Jotai like state management library for Roact, Roact Hooks and React Lua

[!WARNING]
This library is wip. Breaking changes may occur.

Installation

Method 1: File (Roblox Studio)

  • Download the rbxm model file from the Github release page.
  • Insert the model into Roblox Studio into a place like ReplicatedStorage

Method 2: Wally

  • Add this like to your wally.toml file
rotai = "piquu/rotai@0.1.0"

Todo

  • Add support for react lua
  • Write better Documentation
  • Optimize useAtom for Roact
  • Add support for Roblox Ts

Documentation

local Roact = require(path.to.roact)
local Rotai = require(path.to.rotai)

local Component = require(path.to.component)

local atom = Rotai.atom(0)

local app = Roact.createElement(Rotai.Roact.Provider(Roact), {
	store = atom,
}, {
	Roact.createElement('ScreenGui', nil, {
		Roact.createElement(Component),
	})
})

Roact.mount(app, game.Players.LocalPlayer.PlayerGui)

Component:

local Roact = require(path.to.roact)
local Rotai = require(path.to.rotai)

local Component = Roact.Component:extend('Component')

function Component:init()
	self.count, self.setCount = Rotai.Roact.useAtom(self)
end

function Component:render()
	return Roact.createElement('TextButton', {
		AnchorPoint = Vector2.new(.5, .5),
		Size = UDim2.new(0, 100, 0, 100),
		Position = UDim2.new(.5, 0, .5, 0),
		Text = tostring(self.value()),
		[Roact.Event.MouseButton1Click] = function(_)
			self.setValue(self.value() + 1)
		end,
	})
end

return Rotai.roact.Consumer(Roact)(Component)

License

Rotai is available under the MIT license. See LICENSE for details.

Package Details

Install command (Click to copy)


Version

0.1.6

License

MIT

check_circle

Safe for commercial use

infoThe package archive does not include its license text; the license is declared in its manifest metadata.

Automated license review — not legal advice.