schedule method

void schedule(
  1. Iterable<PluginChange> changes
)

Makes changes — a recorded run's journal — at their steps, through applyPending, as a replay reaches them.

Changes at one step are made in the order given, which is the order they were journalled in.

Implementation

void schedule(Iterable<PluginChange> changes) {
  final all = <PluginChange>[..._scheduled, ...changes];
  // `List.sort` is not stable, and two changes at one step — an enable and
  // a reorder — must stay in the order they were made.
  final order = List<int>.generate(all.length, (i) => i)
    ..sort((a, b) {
      final byStep = all[a].step.compareTo(all[b].step);
      return byStep != 0 ? byStep : a.compareTo(b);
    });
  _scheduled
    ..clear()
    ..addAll(<PluginChange>[for (final i in order) all[i]]);
}