Roblox / Roblox/rodux

Middleware to deep-freeze all state

Open
#16 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blocked enhancement
Dominant language
Lua
Stars
334
Forks
78
PR merge metrics
No merged PRs in 30d

Description

It'd be cool to have a middleware that automatically makes all items in the store read-only. It'd be similar to the JS package 'deep-freeze', but probably throw errors on mutations instead of silently ignoring them.

Speed of implementation doesn't really matter here, since it'd only be a development tool.

Implementing this in Lua 5.1 might be tricky. Normally for a read-only table, I'd create a new table with __index and __newindex metamethods acting as a proxy, but then you wouldn't be able to iterate (or shallow copy) the table! In 5.2, Lua gained __pairs and __ipairs which would've helped here, but alas.

There might be one edge case in this implementation. Way back when I first used Redux, I would keep JS Promise objects in the store as a way to manage request status. Promise objects have internal mutability, which we might consider to be breaking the Redux paradigm, but because it's not observable outside of attaching a handler to the promise, I don't know if it is. If we wanted to support a use case like that, we'd need to make sure not to deep-freeze some objects, or force Promise objects to be userdata instead.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points; first locate the store and middleware APIs in the repository and review how state is exposed. Clarify the Lua 5.1 iteration and Promise-like userdata cases before defining completion as development-time mutation errors for nested state.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.