|
| 1 | +# Fluid Mixins |
| 2 | + |
| 3 | +- [register_default](#register_default) |
| 4 | +- [register_named](#register_named) |
| 5 | +- [get_default](#get_default) |
| 6 | +- [get_named](#get_named) |
| 7 | +- [apply_named](#apply_named) |
| 8 | +- [apply_table](#apply_table) |
| 9 | + |
| 10 | +## register_default |
| 11 | + |
| 12 | +```lua |
| 13 | +fluid_mixins.register_default(class, prop[, value]) |
| 14 | +``` |
| 15 | + |
| 16 | +Register a mixin for a Finale class that will be applied globally. Note that methods are applied retroactively but properties will only be applied to new instances. |
| 17 | + |
| 18 | + |
| 19 | +| Input | Type | Description | |
| 20 | +| --- | --- | --- | |
| 21 | +| `class` | `string\|array` | The class (or an array of classes) to apply the mixin to. | |
| 22 | +| `prop` | `string\|table` | Either the property name, or a table with pairs of (string) = (mixed) | |
| 23 | +@ value [mixed] OPTIONAL: Method or property value. Will be ignored if prop is a table. |
| 24 | + |
| 25 | +## register_named |
| 26 | + |
| 27 | +```lua |
| 28 | +fluid_mixins.register_named(class, mixin_name, prop[, value]) |
| 29 | +``` |
| 30 | + |
| 31 | +Register a named mixin which can then be applied by calling apply_named. If a named mixin requires setup, include a method called `init` that accepts zero arguments. It will be called when the mixin is applied. |
| 32 | + |
| 33 | + |
| 34 | +| Input | Type | Description | |
| 35 | +| --- | --- | --- | |
| 36 | +| `class` | `string\|array` | The class (or an array of classes) to apply the mixin to. | |
| 37 | +| `mixin_name` | `string\|array` | Mixin name, or an array of names. | |
| 38 | +| `prop` | `string\|table` | Either the property name, or a table with pairs of (string) = (mixed) | |
| 39 | +@ value [mixed] OPTIONAL: Method or property value. Will be ignored if prop is a table. |
| 40 | + |
| 41 | +## get_default |
| 42 | + |
| 43 | +```lua |
| 44 | +fluid_mixins.get_default(class, prop) |
| 45 | +``` |
| 46 | + |
| 47 | +Retrieves the value of a default mixin. |
| 48 | + |
| 49 | + |
| 50 | +| Input | Type | Description | |
| 51 | +| --- | --- | --- | |
| 52 | +| `class` | `string` | The Finale class name. | |
| 53 | +| `prop` | `string` | The name of the property or method. | |
| 54 | + |
| 55 | +| Output type | Description | |
| 56 | +| --- | --- | |
| 57 | +| `mixed\|nil` | If the value is a table, a copy will be returned. | |
| 58 | + |
| 59 | +## get_named |
| 60 | + |
| 61 | +```lua |
| 62 | +fluid_mixins.get_named(class, mixin_name) |
| 63 | +``` |
| 64 | + |
| 65 | +Retrieves all the methods / properties of a named mixin. |
| 66 | + |
| 67 | + |
| 68 | +| Input | Type | Description | |
| 69 | +| --- | --- | --- | |
| 70 | +| `class` | `string` | Finale class. | |
| 71 | +| `mixin_name` | `string` | Name of mixin. | |
| 72 | + |
| 73 | +| Output type | Description | |
| 74 | +| --- | --- | |
| 75 | +| `table\|nil` | | |
| 76 | + |
| 77 | +## apply_named |
| 78 | + |
| 79 | +```lua |
| 80 | +fluid_mixins.apply_named(object, mixin_name) |
| 81 | +``` |
| 82 | + |
| 83 | +Applies a named mixin to an object. See apply_table for more details. |
| 84 | + |
| 85 | + |
| 86 | +| Input | Type | Description | |
| 87 | +| --- | --- | --- | |
| 88 | +| `object` | `__FCBase` | The object to apply the mixin to. | |
| 89 | +| `mixin_name` | `string` | The name of the mixin to apply. | |
| 90 | + |
| 91 | +| Output type | Description | |
| 92 | +| --- | --- | |
| 93 | +| `__FCBase` | The object that was passed. | |
| 94 | + |
| 95 | +## apply_table |
| 96 | + |
| 97 | +```lua |
| 98 | +fluid_mixins.apply_table(object, table) |
| 99 | +``` |
| 100 | + |
| 101 | +Takes all pairs in the table and copies them over to the target object. If there is an `init` method, it will be called and then removed. This method does not check for conflicts sonit may result in another mixin's method / property being overwritten. |
| 102 | + |
| 103 | + |
| 104 | +| Input | Type | Description | |
| 105 | +| --- | --- | --- | |
| 106 | +| `object` | `__FCBase` | The target object. | |
| 107 | +| `mixin_table` | `table` | Table of properties to apply_table | |
| 108 | + |
| 109 | +| Output type | Description | |
| 110 | +| --- | --- | |
| 111 | +| `__FCBase` | The object that was passed. | |
0 commit comments