Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Persistent storage service for Sinix apps #8

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/event_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,16 @@ pub fn sinix_install(mut webview: tauri::WebviewMut, msg: Option<String>) {
)
.expect("failed to emit");
}

pub fn database(mut webview: tauri::WebviewMut, msg: Option<String>) {
let reply = Reply {
data: "response".to_string(),
};

tauri::event::emit(
&mut webview,
String::from("sinix-database-response"),
Some(serde_json::to_string(&reply).unwrap()),
)
.expect("failed to emit");
}
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ pub fn tauri_handler(webview: &mut Webview, _source: String) {
// handler function for tauri app setup callback

let webview = webview.as_mut();
let webview_clone = webview.clone();

tauri::event::listen(String::from("sinix-install"), move |msg| {
event_handlers::sinix_install(webview.clone(), msg)
event_handlers::sinix_install(webview_clone.clone(), msg);
});

let webview_clone = webview.clone();

tauri::event::listen(String::from("sinix-database"), move |msg| {
event_handlers::database(webview_clone.clone(), msg);
});
}

Expand Down