lua-redux - A predictable state container for Lua apps

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
zebMcCorkle
Prole
Posts: 1
Joined: Wed Dec 14, 2016 1:27 am

lua-redux - A predictable state container for Lua apps

Post by zebMcCorkle »

This library was originally made for LÖVE, however it will work in any Lua environment. It follows the same API as JavaScript Redux.

Download: https://github.com/zebMcCorkle/lua-redux

The example on the Redux home page is in example.lua.

From GitHub:

lua-redux

Redux reimplemented in Lua. Follows the same API as Redux.

Be sure to use

Code: Select all

:
to refer to member functions on state!
User avatar
pgimeno
Party member
Posts: 3551
Joined: Sun Oct 18, 2015 2:58 pm

Re: lua-redux - A predictable state container for Lua apps

Post by pgimeno »

Hello, welcome to the forum!

Can you tell us examples of use cases for this?

If I've understood it properly, it sounds like an undo/redo feature (e.g. of a text editor) would be one clear use case. I'd like to know if I got it right, and about other examples.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: lua-redux - A predictable state container for Lua apps

Post by alloyed »

This is sort of secondhand knowledge, because I haven't used redux myself, but I've heard it described as a command pattern-turned-framework. Instead of changing your game's state directly, you issue commands that some other part of your app knows how to interpret.
This has sort-of the same effect as using an external DB: you get a nice log of all the ways your app's state has changed, and since it forces immutability you get things like multi-level undo/append only storage for free. The other part, and this probably matters more for a webapp than a game, is that you can attach watches to commands, now that you've reified them. So you can update X part of the dom only when you know a command has changed its part of the world and so on.

My gamestate actually looks a bit like this, except I stumbled upon it by accident so it's mixed up with a bunch of other stuff. I might check this out to see if it clarifies my design a bit.
User avatar
pgimeno
Party member
Posts: 3551
Joined: Sun Oct 18, 2015 2:58 pm

Re: lua-redux - A predictable state container for Lua apps

Post by pgimeno »

Thanks for the detailed explanation, alloyed.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 49 guests