Integration
Add the UI component to your application based on your targeted platform.
Compose Multiplatform (Common)¶
- Use
KtorMonitorComposable
Android¶
- If
showNotifcation = trueand android.permission.POST_NOTIFICATIONS is granted, the library will display a notification showing a summary of ongoing KTOR activity. Tapping on the notification launches the fullKtorMonitor. - Apps can optionally use the
KtorMonitor()Composable directly into own Composable code. - For Android minSdk < 26, Core Library Desugaring is required.
iOS¶
-
If
showNotifcation = trueand notification permission is granted, the library will display a notification showing a summary of ongoing KTOR activity. -
Use
KtorMonitorViewController
struct KtorMonitorView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
struct ContentView: View {
var body: some View {
KtorMonitorView()
.ignoresSafeArea()
}
}
Desktop (Compose)¶
- Use
KtorMonitorWindowComposable
fun main() = application {
var showKtorMonitor by rememberSaveable { mutableStateOf(false) }
KtorMonitorWindow(
onCloseRequest = { showKtorMonitor = false },
show = showKtorMonitor
)
}
- Use
KtorMonitorWindowComposable withKtorMonitorMenuItem
fun main() = application {
var showKtorMonitor by rememberSaveable { mutableStateOf(false) }
Tray(
icon = painterResource(Res.drawable.ic_launcher),
menu = {
KtorMonitorMenuItem { showKtorMonitor = true }
}
)
KtorMonitorWindow(
show = showKtorMonitor,
onCloseRequest = { showKtorMonitor = false }
)
}
Desktop (Swing)¶
- Use
KtorMonitorPanelSwing Panel
fun main() = application {
SwingUtilities.invokeLater {
val frame = JFrame()
frame.add(KtorMonitorPanel, BorderLayout.CENTER)
frame.isVisible = true
}
}
Wasm / Js¶
- Web targets store the data with SQLite WASM and need a small Web Worker (
WebWorkerSQLiteDriverdoes not ship one). Copysqlite.worker.jsinto your web project (e.g.{project}/webpack-resources/sqlite.worker.js) and alias it in webpack. The data is kept in memory, so no special HTTP headers are required.
// {project}/webpack.config.d/sqlite.js
const path = require('path');
config.resolve = {
modules: ['node_modules', path.resolve(__dirname, '../../node_modules')],
fallback: {
fs: false,
path: false,
crypto: false,
os: false,
},
alias: {
...(config.resolve && config.resolve.alias),
'ktor-monitor-sqlite-worker/sqlite.worker.js': path.resolve(__dirname, '../../../../webpack-resources/sqlite.worker.js'),
},
};