subscribeEvents method
Implementation
Future<StreamSubscription<Events>> subscribeEvents(
BlockHash at, Function(Events) onData) async {
latestRuntimeMetadata = await getMetadata();
final subscription = await _provider.subscribe('state_subscribeStorage', [
['0x${hex.encode(at)}']
], onCancel: (subscription) async {
await _provider.send('state_unsubscribeStorage', [subscription]);
});
return subscription.stream.map((response) {
return Events.fromJson(response.result, latestRuntimeMetadata.chainInfo);
}).listen(onData);
}