EventSourceOutsideBrowser class abstract

Implemented by EventSource outside browser.

Example

import 'package:universal_html/html.dart';
import 'dart:io' show Cookie;

Future<void> main() async {
  final eventSource = EventSource('http://example.com/events');
  if (eventSource is EventSourceOutsideBrowser) {
    eventSource.onHttpClientRequest = (eventSource, request) {
      request.headers.set('Authorization', 'example');
      request.cookies.add(Cookie('name', 'value'));
    };
    eventSource.onHttpClientRequest = (eventSource, request, response) {
      // ...
    };
  }
  await for (var message in eventSource.onMessage) {
    print('Event:');
    print('  type: ${message.type}');
    print('  data: ${message.data}');
  }
}

Constructs EventSource and allows HTTP request modifications if the application is not running in browser.

Implemented types

Constructors

EventSourceOutsideBrowser()

Properties

hashCode → int
The hash code for this object.
no setterinherited
on → Events
no setterinherited
onError → Stream<Event>
no setterinherited
onHttpClientRequest ↔ FutureOr<void> Function(EventSourceOutsideBrowser eventSource, HttpClientRequest request)?
A callback called when a HttpClientRequest is ready (only outside browsers).
getter/setter pair
onHttpClientResponse ↔ FutureOr<void> Function(EventSourceOutsideBrowser eventSource, HttpClientRequest request, HttpClientResponse response)?
A callback called when a HttpClientResponse arrives (only outside browsers).
getter/setter pair
onMessage → Stream<MessageEvent>
no setterinherited
onOpen → Stream<Event>
no setterinherited
readyState → int?
no setterinherited
retryDuration ↔ Duration
Current timeout.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
url → String
URL of this event source.
no setterinherited
withCredentials → bool?
Value of withCredentials given in the constructor.
no setterinherited

Methods

addEventListener(String type, EventListener listener, [bool? useCapture]) → void
inherited
close() → void
Closes the event stream.
inherited
dispatchEvent(Event event) → bool
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeEventListener(String type, EventListener listener, [bool? useCapture]) → void
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited