import 'dart:typed_data';
import 'package:js/js.dart';

@JS()
@staticInterop
class StreamingFetcher {
  external factory StreamingFetcher(
    String url,
    StreamingFetcherCallbacks callbacks,
  );
}

extension StreamingFetcherIntanceMembers on StreamingFetcher {
  external void testCallback();
  external void start();
  external void stop();
}

class StreamingFetcherCallbacks {
  void Function(Uint8List bytes)? onBuffer;
  void Function()? onDone;
  void Function(String message)? onError;

  StreamingFetcherCallbacks({
    this.onBuffer,
    this.onDone,
    this.onError,
  });
}
