Mengubah daftar respon dari map ke jsarray #3
@@ -11,6 +11,7 @@ import app.tauri.annotation.InvokeArg
|
|||||||
import app.tauri.annotation.Permission
|
import app.tauri.annotation.Permission
|
||||||
import app.tauri.annotation.TauriPlugin
|
import app.tauri.annotation.TauriPlugin
|
||||||
import app.tauri.plugin.Invoke
|
import app.tauri.plugin.Invoke
|
||||||
|
import app.tauri.plugin.JSArray
|
||||||
import app.tauri.plugin.JSObject
|
import app.tauri.plugin.JSObject
|
||||||
import app.tauri.plugin.Plugin
|
import app.tauri.plugin.Plugin
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
@@ -45,11 +46,12 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val daftarRes = adapter.bondedDevices.map { i ->
|
val daftarRes = JSArray()
|
||||||
mapOf(
|
adapter.bondedDevices.map { i ->
|
||||||
"nama" to (i.name ?: "Unknown"),
|
val res = JSObject()
|
||||||
"alamat" to i.address
|
res.put("nama", i.name ?: "Unknown")
|
||||||
)
|
res.put("alamat", i.address)
|
||||||
|
daftarRes.put(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
val objekDaftarRes = JSObject()
|
val objekDaftarRes = JSObject()
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ use crate::Result;
|
|||||||
#[command]
|
#[command]
|
||||||
pub(crate) async fn daftar_perangkat<R: Runtime>(
|
pub(crate) async fn daftar_perangkat<R: Runtime>(
|
||||||
app: AppHandle<R>,
|
app: AppHandle<R>,
|
||||||
) -> Result<SDaftarPerangkatBlueclasClassicResponDaftarPerangkat> {
|
) -> Result<SBlueclasClassicResponDaftarPerangkat> {
|
||||||
return app.bluclas().daftar_perangkat();
|
return app.bluclas().daftar_perangkat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-7
@@ -14,13 +14,8 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
|||||||
pub struct Bluclas<R: Runtime>(AppHandle<R>);
|
pub struct Bluclas<R: Runtime>(AppHandle<R>);
|
||||||
|
|
||||||
impl<R: Runtime> Bluclas<R> {
|
impl<R: Runtime> Bluclas<R> {
|
||||||
pub fn daftar_perangkat(
|
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasClassicResponDaftarPerangkat> {
|
||||||
&self,
|
return Ok(SBlueclasClassicResponDaftarPerangkat { data: vec![] });
|
||||||
) -> crate::Result<SDaftarPerangkatBlueclasClassicResponDaftarPerangkat> {
|
|
||||||
return Ok(SDaftarPerangkatBlueclasClassicResponDaftarPerangkat {
|
|
||||||
nama: String::new(),
|
|
||||||
alamat: String::new(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kirim(&self, _: SBlueclasClassicMuatanKirim) -> crate::Result<()> {
|
pub fn kirim(&self, _: SBlueclasClassicMuatanKirim) -> crate::Result<()> {
|
||||||
|
|||||||
+1
-3
@@ -25,9 +25,7 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
|||||||
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
||||||
|
|
||||||
impl<R: Runtime> Bluclas<R> {
|
impl<R: Runtime> Bluclas<R> {
|
||||||
pub fn daftar_perangkat(
|
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasClassicResponDaftarPerangkat> {
|
||||||
&self,
|
|
||||||
) -> crate::Result<SDaftarPerangkatBlueclasClassicResponDaftarPerangkat> {
|
|
||||||
return self
|
return self
|
||||||
.0
|
.0
|
||||||
.run_mobile_plugin("daftarPerangkat", ())
|
.run_mobile_plugin("daftarPerangkat", ())
|
||||||
|
|||||||
Reference in New Issue
Block a user