Add support of async-await in event handlers
ashalva opened this issue · comments
Steps to Reproduce the Problem
Trying to use async-await inside willSendReportHandler
. I have an actor which holds the information which I want to attach to the logs before user submits the report.
import Instabug
class InstabugTesting {
private let featureProvider = SomeFeatureProvider()
func setupWillSendReportObserver() {
Instabug.willSendReportHandler = { [weak self] report in // <-- Invalid conversion from 'async' function of type '(IBGReport) async -> IBGReport' to synchronous function type '(IBGReport) -> IBGReport'
guard let self else { return report }
let features = await self.featureProvider.features
for feature in features {
IBGLog.logInfo(feature)
}
return report
}
}
}
actor SomeFeatureProvider {
var features: [String] = []
func addFeature(_ feature: String) {
features.append(feature)
}
}
The error makes sense from current API standpoint, but having the async callbacks or any other ways support async-await calls would ease developers' lives.
Expected Behavior
Ideally support of async-await for event handlers 🥺
Actual Behavior
Compiler error 👇
![image](https://private-user-images.githubusercontent.com/9494262/280674834-e8765f82-7201-47f7-ac75-0cbd20dffa3d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzOTYyNzksIm5iZiI6MTcyNDM5NTk3OSwicGF0aCI6Ii85NDk0MjYyLzI4MDY3NDgzNC1lODc2NWY4Mi03MjAxLTQ3ZjctYWM3NS0wY2JkMjBkZmZhM2QucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjNUMDY1MjU5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTk3NGMzNzQwNGE2OTRlMzM2YTM0NDAzMGI2NWYzYjA5Njg1MzUxZTU1NzdkNzQxZDM4NjliZDMzOTcyZjVjNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.dmkdmYOPVVTehQlOPIZ-dK5vFrhmErP4DH1dB3cg62c)
Instabug integration code
Make sure to remove your app token.
SDK Version
12.2.0
iOS Version
Any
Device Model
Any
[Optional] Project That Reproduces the Issue
Reproducable with attached code snippet
This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed due to inactivity.