Skip to content

Implement robot injector mechanism

Tom JORQUERA requested to merge tjorquera/hublot:issue-7 into master

Add some mechanisms for robot code injection in the client, defined in lib/controller.js.

The code injection is based on the notion of "modules": a module named foo is a folder named foo at the root of the modules directory (currently ./client) containing a file named foo.js along with other source files. The foo/foo.js file is mandatory and is meant to be loaded before any other files of the modules.

The controller.loadAll method allow to get a list containing all the sources for all the required modules in a given order. The elements of the list match the required loading order, meaning they can be directly be loaded one after the other.

The application now uses this mechanism to load 3 modules (in the following order):

  • client/controller: in charge of exposing the hubl.in functions as a unified API
  • client/lib: containing various libraries to be used by the robot
  • client/robot: containing the behavior of the robot itself

Fixes #7 (closed)

Merge request reports