如何将多个反应合并为一个

How to merge many reactions into one

我有很多反应,所有反应都在调用同一个函数。

late List<ReactionDisposer> _disposers;
_disposers = [
  reaction((_) => gameMode, (_) => _apply),
  reaction((_) => level, (_) => _apply),
  reaction((_) => round, (_) => _apply),
  reaction((_) => timeoutInSec, (_) => _apply),
  reaction((_) => hostage, (_) => _apply),
  reaction((_) => upTime, (_) => _apply),
];

如何像下面这样合并到一个反应中?

_disposers = [
  reaction((_) => gameMode|level|round|timeoutInSec|hostage|upTime, (_) => _apply),
];

我想你可以使用这个代码:

final _disposers = [
  gameMode,
  level, 
  round,
  timeoutInSec,
  hostage,
  uptime,
].map((func) =>
  reaction((_) => func, (_) => apply))
    .toList();