Skip to content

[Discussions] Adding a new log before emitting an event #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RanKKI opened this issue Apr 3, 2024 · 0 comments
Open

[Discussions] Adding a new log before emitting an event #10

RanKKI opened this issue Apr 3, 2024 · 0 comments
Assignees

Comments

@RanKKI
Copy link

RanKKI commented Apr 3, 2024

Content

  _addRawLog(Log log) {
...
    if (log.type == LogType.error) {
      _hasError = true;
      _emit(FlowLogEvent.error, this);
    } else {
      _emit(FlowLogEvent.log, this);
    }
    this.logs!.add(log);
...
  }

The 'newLog' event will be emitted before it is added to the logs, which means the listener has no way to know the content of the latest log.

I think it's better to move the _emit part after this.logs!.add(log), so the listener is able to access the latest log by using logs[logs.length - 1]

Also, it is possible to change List<Log>? logs to List<Log> logs by giving a default [], so we don't need to do null-check elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants