# WebViewContext

One WebView as one hook sees it, for the life of the WKWebView.

```swift
protocol WebViewContext : AnyObject
```

## Overview

Call [`emit(_:_:)`](<https://rasmuskard.github.io/react-native-minimal-webview/swift/documentation/minimalwebview/webviewcontext/emit(_-_-)/index.md>) and [`ask(_:_:_:)`](<https://rasmuskard.github.io/react-native-minimal-webview/swift/documentation/minimalwebview/webviewcontext/ask(_-_-_-)/index.md>) from any thread, and the rest on the main thread, where `configure`, `attach`, the handlers and the answers run.

A context kept after the view closed does nothing.

A hook is on while its extension’s `options` are not null or false; [`HookExtension.options`](<https://rasmuskard.github.io/react-native-minimal-webview/typescript/react-native-minimal-webview/type-aliases/HookExtension/#options>) says what off means.

Values from JS arrive as Foundation’s JSON types: a number as `NSNumber`, an object as `NSDictionary`, an array as `NSArray`. In an ask’s answer and a [`handle(_:_:)`](<https://rasmuskard.github.io/react-native-minimal-webview/swift/documentation/minimalwebview/webviewcontext/handle(_-_-)/index.md>) handler’s arguments, null is nil at the top level and `NSNull` inside an array or object.

## See Also

[Native hooks guide](<https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/>)
