vinum-team / Vinum

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

Force all public places that accept `EitherState<T>` to also accept `T` #44

Closed xiyler closed 5 months ago

xiyler commented 6 months ago

It could increase the productivity and the reusability in your code so that you don't have to worry about adding specific support for normal luau types.

If this is added, then something like so is very possible:

local IS_BAD = true

On(IS_BAD, function()
  -- doesn't run at all.
end)

print(Read(IS_BAD)) -- prints true

However, it's important to note that we should still have operators like Write to still work on state structs only, since calling Write on normal luau variables is almost always a mistake.

This is deferred to Vinum 0.5.

xiyler commented 5 months ago

While this indeed has advantages, it complicates and blurs the exact goal of Vinum's public functions (e.g does Read act as a simple :get()-like call, or generally "a reader function that reads data"?). Closed until there is evident need for such feature in the core library.