# ask(\_:\_:\_:)

Sends the event as [`emit(_:_:)`](<https://rasmuskard.github.io/react-native-minimal-webview/swift/documentation/minimalwebview/webviewcontext/emit(_-_-)/index.md>) does, but to the extension’s `onAsk` when it has one, and calls `onAnswer` with that handler’s return value, a promise awaited.

```swift
func ask(_ name: String, _ payload: [String : Any], _ onAnswer: @escaping (Any?) -> Void)
```

## Discussion

It answers nil when the handler throws or there is none, or when the Document ends first; there is no timeout. It answers nil at once while the hook is off, and after the view closed. An ask made before the first commit (in `attach`, or after a crash) belongs to the Document that commit opens.
