From a81f8389df9f7b7e21250807099ae5813ff2735e Mon Sep 17 00:00:00 2001 From: minoic Date: Tue, 3 Dec 2024 20:11:11 -0800 Subject: [PATCH] update: use if instead of switch case in xhr_transport.dart --- lib/src/client/transport/xhr_transport.dart | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/src/client/transport/xhr_transport.dart b/lib/src/client/transport/xhr_transport.dart index 69cb78a8..1de0eb78 100644 --- a/lib/src/client/transport/xhr_transport.dart +++ b/lib/src/client/transport/xhr_transport.dart @@ -59,14 +59,12 @@ class XhrTransportStream implements GrpcTransportStream { if (_incomingProcessor.isClosed) { return; } - switch (_request.readyState) { - case 2: - _onHeadersReceived(); - break; - case 4: - _onRequestDone(); - _close(); - break; + // TODO: dart-lang/web#285 use 'if' for now + if (_request.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + _onHeadersReceived(); + } else if (_request.readyState == XMLHttpRequest.DONE) { + _onRequestDone(); + _close(); } });