Closed delucis closed 4 years ago
Yes, I think we should stop allowing arbitrary keys in the game config.
The pattern of passing in args to a plugin factory sounds good to me, and would require almost no changes to boardgame.io. We'd just need to migrate PluginPlayer
.
Following on from working on #598, I have a question about plugin configuration.
The player plugin expects a
playerSetup
function in the game config. Do you think there should be a more specific namespace for plugin configuration? Or a way of cleanly associating plugins with their configuration, so that methods don’t clutter up the main game config object? For example, apluginsConfig
object could be keyed by plugin name, and hand the value of that field to the plugin methods:This could also make it easier to enforce correct types for Typescript users. For now, I allowed any arbitrary key–value pair in the game config, but that’s not great, because it reduces type-checking for misspelled keys.
An alternative might be to encourage a pattern where plugins that need configuring provide a plugin factory that takes the configuration options and returns a plugin, with no need for custom fields in the game config: