-
Notifications
You must be signed in to change notification settings - Fork 320
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
- Loading branch information
1 parent
673e4ff
commit 75c8847
Showing
7 changed files
with
65 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,20 @@ | ||
package maestro.utils | ||
|
||
object Insights { | ||
object Insights: InsightsInterface { | ||
|
||
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) { | ||
Insights.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 InsightsInterface { | ||
|
||
fun report(insight: Insight) | ||
|
||
fun onInsightsUpdated(callback: (Insight) -> Unit) | ||
|
||
fun unregisterListener(callback: (Insight) -> Unit) | ||
} | ||
|
||
object NoopInsights: InsightsInterface { | ||
|
||
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 | ||
} | ||
} |