setRSIMRuntimeEventObservers function

void setRSIMRuntimeEventObservers(
  1. RSIMEngine engine, {
  2. void onAppStateChanged(
    1. RSIMAppState state
    )?,
  3. void onNetworkChanged(
    1. RSIMNetworkType network
    )?,
})

由上层适配器注入平台事件观察点。

仅供 RCIMIWEngine 在 attach 时调用;通过库级注册表关联引擎实例, 不扩大 RSIMEngine 的公开调用面。

Implementation

void setRSIMRuntimeEventObservers(
  RSIMEngine engine, {
  void Function(RSIMAppState state)? onAppStateChanged,
  void Function(RSIMNetworkType network)? onNetworkChanged,
}) {
  if (onAppStateChanged == null && onNetworkChanged == null) {
    _runtimeEventObservers[engine] = null;
    return;
  }
  _runtimeEventObservers[engine] = _RSIMRuntimeEventObservers(
    onAppStateChanged: onAppStateChanged,
    onNetworkChanged: onNetworkChanged,
  );
}