refactor logs processing
Summary: The log plugin subscribed to the device logs, when it was mounted. Then, the device replayed all log messages that happened in before the plugin became active. While this works, this was not the most performant way to handle this, because it caused multiple rerenders. In this diff, a method is added to `BaseDevice` to get all buffered logs. This method is called once the logs plugin becomes active. The processing of the logs is split into a couple smaller functions. Reviewed By: jknoxville Differential Revision: D13376393 fbshipit-source-id: bb151659c3335e10f647ae2dbf66e93b32d22913
This commit is contained in:
committed by
Facebook Github Bot
parent
64b5e66168
commit
4546e64509
@@ -78,7 +78,6 @@ export default class BaseDevice {
|
||||
addLogListener(callback: DeviceLogListener): Symbol {
|
||||
const id = Symbol();
|
||||
this.logListeners.set(id, callback);
|
||||
this.logEntries.map(callback);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -89,6 +88,10 @@ export default class BaseDevice {
|
||||
}
|
||||
}
|
||||
|
||||
getLogs() {
|
||||
return this.logEntries;
|
||||
}
|
||||
|
||||
removeLogListener(id: Symbol) {
|
||||
this.logListeners.delete(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user