Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Step 1: Stop thinking like a Java programmer.</p> <p>You're in <em>Lua</em> now. There are no classes with explicit and compile-time fixed prototypes. Functions are first-class objects; they are <em>values</em>. So break the problem down in that way.</p> <p>You have a bunch of "rules" (ie: functions). You want to apply some of those rules to certain data. You have a configuration system that says, "When applying rules to data from location X, use this set of rules." So... do that.</p> <p>You detect that data comes from location X. So you call your configuration logic to build a Lua table for location X that contains your rules (ie: functions) to apply to that data. The configuration logic for location X loads the rules from wherever they are stored, and returns them. If the configuration is in a database or something, then the database entry for location X would probably refer to rules by name.</p> <p>How you convert that rule name into an actual Lua function is up to you, but there are many ways. You could have a registry that preloads all of the Lua files from a directory into a table, and then pick the rule based on names in that table. Or perhaps you have a database of named Lua files/scripts, each of which is a separate rule. There are any number of ways to implement this.</p> <p>In Lua, "dependency injection" is just "deciding how to build collections of functions." It's not a special thing because Lua is a much more free-form language than Java. It's just a matter of where the functions come from, how to put them together in a table, and then how to apply that table to some data. And all of those are up to you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload