-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use noop insights by default on maestro (#2131)
- Loading branch information
1 parent
759d954
commit 17e67dc
Showing
10 changed files
with
84 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,20 @@ | ||
package maestro.utils | ||
|
||
object Insights { | ||
object CliInsights: Insights { | ||
|
||
private var insight: Insight = Insight("", Insight.Level.NONE) | ||
private val listeners = mutableListOf<(Insight) -> Unit>() | ||
|
||
fun report(insight: Insight) { | ||
this.insight = insight | ||
override fun report(insight: Insight) { | ||
CliInsights.insight = insight | ||
listeners.forEach { it.invoke(insight) } | ||
} | ||
|
||
fun onInsightsUpdated(callback: (Insight) -> Unit) { | ||
override fun onInsightsUpdated(callback: (Insight) -> Unit) { | ||
listeners.add(callback) | ||
} | ||
|
||
fun unregisterListener(callback: (Insight) -> Unit) { | ||
override fun unregisterListener(callback: (Insight) -> Unit) { | ||
listeners.remove(callback) | ||
} | ||
} | ||
|
||
data class Insight( | ||
val message: String, | ||
val level: Level | ||
) { | ||
enum class Level { | ||
WARNING, | ||
INFO, | ||
NONE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package maestro.utils | ||
|
||
interface Insights { | ||
|
||
fun report(insight: Insight) | ||
|
||
fun onInsightsUpdated(callback: (Insight) -> Unit) | ||
|
||
fun unregisterListener(callback: (Insight) -> Unit) | ||
} | ||
|
||
object NoopInsights: Insights { | ||
|
||
override fun report(insight: Insight) { | ||
/* no-op */ | ||
} | ||
|
||
override fun onInsightsUpdated(callback: (Insight) -> Unit) { | ||
/* no-op */ | ||
} | ||
|
||
override fun unregisterListener(callback: (Insight) -> Unit) { | ||
/* no-op */ | ||
} | ||
|
||
} | ||
|
||
|
||
data class Insight( | ||
val message: String, | ||
val level: Level | ||
) { | ||
enum class Level { | ||
WARNING, | ||
INFO, | ||
NONE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters