Skip to content

Commit 6e374f3

Browse files
committed
Adds docs for expose allowedOrigins parameter
1 parent 0b2e57e commit 6e374f3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ onconnect = function (event) {
152152

153153
## API
154154

155-
### `Comlink.wrap(endpoint)` and `Comlink.expose(value, endpoint?)`
155+
### `Comlink.wrap(endpoint)` and `Comlink.expose(value, endpoint?, allowedOrigins?)`
156156

157-
Comlink’s goal is to make _exposed_ values from one thread available in the other. `expose` exposes `value` on `endpoint`, where `endpoint` is a [`postMessage`-like interface][endpoint].
157+
Comlink’s goal is to make _exposed_ values from one thread available in the other. `expose` exposes `value` on `endpoint`, where `endpoint` is a [`postMessage`-like interface][endpoint] and `allowedOrigins` is an array of
158+
RegExp or strings defining which origins should be allowed access (defaults to special case of `['*']` for all origins).
158159

159160
`wrap` wraps the _other_ end of the message channel and returns a proxy. The proxy will have all properties and functions of the exposed value, but access and invocations are inherently asynchronous. This means that a function that returns a number will now return _a promise_ for a number. **As a rule of thumb: If you are using the proxy, put `await` in front of it.** Exceptions will be caught and re-thrown on the other side.
160161

0 commit comments

Comments
 (0)