The Prefer module was turned into a class instead of standalone functions. This is due to the need for a connection to UserInputService.LastInputTypeChanged at the root of the functionality. With just a list of functions, this event had to be connected within the root of the module code, which was not possible to disconnect. This is problematic for testing code. By wrapping it in a class, the event will only be connected if the class is instantiated, and offers a destroy method to disconnect the event.
An alternative would be to have another function that acted as a "startup" for the module's functionality. This, however, would feel unordinary. Thus, adding a class seemed to be the most ergonomic decision.
The
Prefer
module was turned into a class instead of standalone functions. This is due to the need for a connection toUserInputService.LastInputTypeChanged
at the root of the functionality. With just a list of functions, this event had to be connected within the root of the module code, which was not possible to disconnect. This is problematic for testing code. By wrapping it in a class, the event will only be connected if the class is instantiated, and offers adestroy
method to disconnect the event.