subscribeRuntimeVersion method

Future<StreamSubscription<RuntimeVersion>> subscribeRuntimeVersion(
  1. dynamic onData(
    1. RuntimeVersion
    )
)

Retrieves the runtime version via subscription

Implementation

Future<StreamSubscription<RuntimeVersion>> subscribeRuntimeVersion(
    Function(RuntimeVersion) onData) async {
  final subscription = await _provider
      .subscribe('state_subscribeRuntimeVersion', const [],
          onCancel: (subscription) async {
    await _provider.send('state_unsubscribeRuntimeVersion', [subscription]);
  });

  return subscription.stream
      .map((response) => RuntimeVersion.fromJson(response.result))
      .listen(onData);
}