reg static method

dynamic reg(
  1. SyncEaseLogic syncEaseLogic, {
  2. bool replace = true,
})

Registers a new instance of SyncEaseLogic.

If an instance with the same type is already registered, disposes the existing instance before registering the new instance.

Implementation

static reg(SyncEaseLogic syncEaseLogic, {bool replace = true}) {
  String typeKey = syncEaseLogic.runtimeType.toString();
  if (Utils.registeredLogics[typeKey] != null && replace) {
    syncEaseLogic.infoLog(
        "A new instance is registered. Disposing the existing instance.");
    Utils.registeredLogics[typeKey] = syncEaseLogic;
    syncEaseLogic.onRegistered(); // Initialize the logic instance
    syncEaseLogic.successLog("Instance registered successfully.");
    return Utils.registeredLogics[typeKey];
  } else {
    Utils.registeredLogics[typeKey] = syncEaseLogic;
    syncEaseLogic.onRegistered(); // Initialize the logic instance
    syncEaseLogic.infoLog("$typeKey is already registered ");
    return Utils.registeredLogics[typeKey];
  }
}