Open tommasobertoni opened 3 years ago
At the moment, the commands are registered and then they're all available to be invoked at any time. Sometimes, though, it would be nice to be able to specify when the commands can be invoked, by dynamically changing the available commands.
Proposal:
interface ICommandsProvider { IReadOnlyList<Command> AvailableCommands { get; } }
The implementation would contain the state machine determining which commands can be executed by the engine:
class CommandsProvider : ICommandsProvider { private readonly State _state; public CommandsProvider(State state /* custom-defined type, not in Covox */) => _state = state; public IReadOnlyList<ICommand> AvailableCommands => ListAvailableCommands(); private IReadOnlyList<ICommand> ListAvailableCommands() { if (state.IsLightOn) return new[] { TurnOffLightsCommand }; else return new[] { TurnOnLightsCommand }; } } // ... covox.UseCommandsProvider(new CommandsProvider());
Covox would invoke ICommandsProvider.AvailableCommands after the speech recognition in order to do the understanding on the available commands.
ICommandsProvider.AvailableCommands
Note: only one source of commands can be used, either RegisterCommands or UseCommandsProvider.
RegisterCommands
UseCommandsProvider
At the moment, the commands are registered and then they're all available to be invoked at any time. Sometimes, though, it would be nice to be able to specify when the commands can be invoked, by dynamically changing the available commands.
Proposal:
The implementation would contain the state machine determining which commands can be executed by the engine:
Covox would invoke
ICommandsProvider.AvailableCommands
after the speech recognition in order to do the understanding on the available commands.Note: only one source of commands can be used, either
RegisterCommands
orUseCommandsProvider
.