Skip to content

Commit 82db14a

Browse files
committed
Fixes from @albrow's Wasm review
1 parent ef5a88d commit 82db14a

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ go get nhooyr.io/websocket
2323
- JSON and ProtoBuf helpers in the [wsjson](https://godoc.org/nhooyr.io/websocket/wsjson) and [wspb](https://godoc.org/nhooyr.io/websocket/wspb) subpackages
2424
- Highly optimized by default
2525
- Concurrent writes out of the box
26-
- [Complete WASM](https://godoc.org/nhooyr.io/websocket#hdr-WASM) support
26+
- [Complete Wasm](https://godoc.org/nhooyr.io/websocket#hdr-Wasm) support
2727

2828
## Roadmap
2929

@@ -130,7 +130,7 @@ The ping API is also nicer. gorilla/websocket requires registering a pong handle
130130
which results in awkward control flow. With nhooyr/websocket you use the Ping method on the Conn
131131
that sends a ping and also waits for the pong.
132132

133-
Additionally, nhooyr.io/websocket can compile to [WASM](https://godoc.org/nhooyr.io/websocket#hdr-WASM) for the browser.
133+
Additionally, nhooyr.io/websocket can compile to [Wasm](https://godoc.org/nhooyr.io/websocket#hdr-Wasm) for the browser.
134134

135135
In terms of performance, the differences mostly depend on your application code. nhooyr/websocket
136136
reuses message buffers out of the box if you use the wsjson and wspb subpackages.

conn_common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file contains *Conn symbols relevant to both
2-
// WASM and non WASM builds.
2+
// Wasm and non Wasm builds.
33

44
package websocket
55

doc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
// Use the errors.As function new in Go 1.13 to check for websocket.CloseError.
1919
// See the CloseError example.
2020
//
21-
// WASM
21+
// Wasm
2222
//
23-
// The client side fully supports compiling to WASM.
23+
// The client side fully supports compiling to Wasm.
2424
// It wraps the WebSocket browser API.
2525
//
2626
// See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
2727
//
28-
// Thus the unsupported features (not compiled in) for WASM are:
28+
// Thus the unsupported features (not compiled in) for Wasm are:
2929
//
3030
// - Accept and AcceptOptions
3131
// - Conn.Ping

frame.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ const (
213213

214214
StatusNoStatusRcvd
215215

216-
// This StatusCode is only exported for use with WASM.
217-
// In non WASM Go, the returned error will indicate whether the connection was closed or not or what happened.
216+
// This StatusCode is only exported for use with Wasm.
217+
// In non Wasm Go, the returned error will indicate whether the connection was closed or not or what happened.
218218
StatusAbnormalClosure
219219

220220
StatusInvalidFramePayloadData
@@ -226,8 +226,8 @@ const (
226226
StatusTryAgainLater
227227
StatusBadGateway
228228

229-
// This StatusCode is only exported for use with WASM.
230-
// In non WASM Go, the returned error will indicate whether there was a TLS handshake failure.
229+
// This StatusCode is only exported for use with Wasm.
230+
// In non Wasm Go, the returned error will indicate whether there was a TLS handshake failure.
231231
StatusTLSHandshake
232232
)
233233

internal/wsjs/wsjs.go renamed to internal/wsjs/wsjs_js.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build js
2-
31
// Package wsjs implements typed access to the browser javascript WebSocket API.
42
//
53
// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
@@ -65,7 +63,7 @@ func (c WebSocket) setBinaryType(typ string) {
6563

6664
func (c WebSocket) addEventListener(eventType string, fn func(e js.Value)) func() {
6765
f := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
68-
fn(args[0])
66+
go fn(args[0])
6967
return nil
7068
})
7169
c.v.Call("addEventListener", eventType, f)

0 commit comments

Comments
 (0)