readBytesOnListen method

void readBytesOnListen(
  1. int bytesSize,
  2. dynamic onData(
    1. Uint8List value
    ),
  3. {void onBefore(
      )?,
    1. Duration dataPollingInterval = const Duration(microseconds: 500)}
    )

    readBytesOnListen can listen data in polling mode, endless loop, you can use onData to get data.

    • dataPollingInterval set data polling interval

    Implementation

    void readBytesOnListen(int bytesSize, Function(Uint8List value) onData,
        {void onBefore()?,
        Duration dataPollingInterval = const Duration(microseconds: 500)}) {
      _readBytesSize = bytesSize;
      readOnListenFunction = onData;
      readOnBeforeFunction = onBefore ?? () {};
    
      _readStream = _lookUpEvent(dataPollingInterval);
      _readStream!.listen((event) {
        readOnListenFunction(event);
      });
    }