This commit is contained in:
Wesley Moore 2024-02-19 16:37:03 +10:00
parent 46ca1b7353
commit b74015f03e
No known key found for this signature in database
4 changed files with 1 additions and 17 deletions

View file

@ -22,7 +22,7 @@ import './style.css'
// ` // `
// setupCounter(document.querySelector('#counter')) // setupCounter(document.querySelector('#counter'))
import { main } from './src/videopls.gleam' import { main } from './src/demo.gleam'
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
const dispatch = main({}); const dispatch = main({});

View file

@ -30,16 +30,3 @@ fn main() {
fn greet(name: &str) -> String { fn greet(name: &str) -> String {
format!("Hello, {}!", name) format!("Hello, {}!", name)
} }
#[tauri::command]
fn clock(app: tauri::AppHandle) {
std::thread::spawn(move || {
loop {
let now = SystemTime::now();
let duration = now.duration_since(UNIX_EPOCH).unwrap();
app.emit_to(EventTarget::any(), "tick", duration.as_secs())
.unwrap();
std::thread::sleep(Duration::from_secs(1));
}
});
}

View file

@ -51,7 +51,6 @@ fn get_greeting(name: String) -> Effect(Msg) {
fn do_get_greeting(name: String, dispatch: fn(Msg) -> Nil) -> Nil { fn do_get_greeting(name: String, dispatch: fn(Msg) -> Nil) -> Nil {
greet(name) greet(name)
// |> promise.await()
|> promise.map(fn(response) { |> promise.map(fn(response) {
case response { case response {
Ok(greeting) -> GotGreeting(greeting) Ok(greeting) -> GotGreeting(greeting)

View file

@ -11,9 +11,7 @@ export async function greet(name) {
} }
export async function listenForTick(handler) { export async function listenForTick(handler) {
console.log("listenForTick");
await listen('tick', (event) => { await listen('tick', (event) => {
console.log(event.payload);
handler(event.payload); handler(event.payload);
}); });
} }