vinum-team / Vinum

A modern reactive state management library for correctness and speed.
MIT License
16 stars 1 forks source link

Allow Groups to hold a table consisting of initial key states #9

Closed sinlerdev closed 1 year ago

sinlerdev commented 1 year ago

Currently, groups can't store initial keys on construction/creation, so developers often have to do something very hacky like this:

local function createGroup(initalState, setProcessor)
    local group = Group(setProcessor)

    for key, state do in initalState do
        group:setKey(key, state)
    end

    return group
end 

createGroup({
    key1 = "state1",
    key2 = "state2"
}, AlwaysTrue)

This can create general confusion between projects (as the implementations of createGroup can include a lot of side effects) and requires external dependencies to perform such a primitive task.

The desired API for said feature is very similar to createGroup, which is to pass a table that contains the initial state, and a set processor.