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
This is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
no setterinherited
onError Stream<Event>
Stream of error events handled by this EventSource.
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>
Stream of message events handled by this EventSource.
no setterinherited
onOpen Stream<Event>
Stream of open events handled by this EventSource.
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?
no setterinherited
withCredentials bool?
no setterinherited

Methods

addEventListener(String type, EventListener? listener, [bool? useCapture]) → void
inherited
close() → void
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