select method

  1. @override
List<MatrixApp> select(
  1. List<MatrixApp> apps,
  2. List<SmfModule> modules
)
override

The apps of apps, apps with every module of modules such as those of everyModuleAppsOf, that the selection takes, in their order.

Implementation

@override
List<MatrixApp> select(List<MatrixApp> apps, List<SmfModule> modules) {
  bool has(MatrixApp app, SmfModule provider) =>
      app.modules.contains(provider.descriptor.id);
  final first = <int>{
    for (final module in modules)
      if (module.descriptor.provides.contains(role))
        if (apps.indexWhere((app) => has(app, module)) case final index
            when index >= 0)
          index,
  };
  return [
    for (final (index, app) in apps.indexed)
      if (first.contains(index)) app,
  ];
}