install<T extends NeuronController> static method

T install<T extends NeuronController>(
  1. T controller
)

Registers a controller and calls its NeuronController.onInit hook.

This method manually registers a controller instance. The controller's NeuronController.onInit method is called immediately after registration.

final controller = MyController();
Neuron.install(controller);

Note: In most cases, use ensure instead, which handles both creation and registration in one call.

Returns the registered controller instance.

See also:

  • ensure - Preferred method that creates and registers if needed
  • use - Get an already installed controller

Implementation

static T install<T extends NeuronController>(T controller) {
  _registry[T] = controller;
  if (NeuronDebugRegistry.instance.isEnabled) {
    NeuronDebugRegistry.instance.registerController(controller);
  }
  controller.onInit();
  return controller;
}