Skip to content

Commit e442a64

Browse files
committed
Add documentation to README
1 parent f99eae7 commit e442a64

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ const proxy = Comlink.wrap(port);
166166
proxy[Comlink.releaseProxy]();
167167
```
168168

169+
If the browser supports the [WeakRef proposal], `releaseProxy()` will be called automatically when the proxy created by `wrap()` gets garbage collected.
170+
171+
### `Comlink.finalizer`
172+
173+
If the object passed to `Comlink.expose()` has a function property `[Comlink.finalizer]`, this function will be called when `releaseProxy()` was called on the other end. Do not that the channel is considered closed at this point and no more communication can happen. This callback is for cleanup only.
174+
169175
### `Comlink.createEndpoint`
170176

171177
Every proxy created by Comlink has the `[createEndpoint]` method.
@@ -206,6 +212,7 @@ Comlink works with Node’s [`worker_threads`][worker_threads] module. Take a lo
206212
[structured clone table]: structured-clone-table.md
207213
[event]: https://developer.mozilla.org/en-US/docs/Web/API/Event
208214
[worker_threads]: https://nodejs.org/api/worker_threads.html
215+
[weakref proposal]: https://github.com/tc39/proposal-weakrefs
209216

210217
## Additional Resources
211218

0 commit comments

Comments
 (0)