RoPinia - A state management like Pinia on Roblox

About

RoPinia is a Pinia state management library ported into Roblox, bringing the simplicity and developer experience of Pinia to Roblox. If you’re already familiar with Pinia, this library provides a familiar approach to creating stores, managing reactive state, and organizing application logic.

Example Usage

init.client.luau:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local pinia = require(ReplicatedStorage.RoPinia)

-- example of stores
local myStore = pinia.store.defineStore("myStore", {
    state = function()
        return {
            hello = "World",
            angka = 10
        };
    end,
    getters = {
        multipleAngka = function(state)
            return state.angka.value * 2
        end
    },
    actions = {
        helloWorld = function(self)
            print(`Hello {self.hello.value}`)
        end,
        sumWithN = function(self, n)
            self.angka.value += n
        end
    }
})

print("My Store")
print(myStore)
print(myStore.angka.value)
print(myStore.multipleAngka.value)

myStore.sumWithN(1)
myStore.multipleAngka:recompute()
print(myStore.angka.value)
print(myStore.multipleAngka.value)

Check our official examples in ./example (Rojo)

Repository

Check RoPinia repository for more information:

Suggestion

Drop your suggestion about this library by reply this post or make an issue on our github repository, your contribution are important to help RoPinia grow bigger. Thank you!

1 Like