Browse Source

Alert component use with await show_popup and read from store content

master
Pheuw1 2 years ago
parent
commit
dc7c79b8ca
  1. 29
      front/volume/src/components/Alert/content.ts

29
front/volume/src/components/Alert/content.ts

@ -1,4 +1,29 @@
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
import Alert__SvelteComponent_ from './Alert.svelte';
export const content = writable("init") export const content = writable("")
export const popup = writable(null) export const popup = writable(null)
import { bind } from 'svelte-simple-modal';
let val;
export async function show_popup(message, form = true) {
popup.set(bind(Alert__SvelteComponent_, {
message,
form
}))
await waitForCondition()
}
export async function waitForCondition() {
const unsub = popup.subscribe((value) => {val = value})
async function checkFlag() {
if (val == null) {
console.log("finished",val)
unsub()
return new Promise(resolve => setTimeout(resolve, 0));
} else {
console.log("waiting")
await new Promise(resolve => setTimeout(resolve, 1000));
return await checkFlag();
}
}
return await checkFlag()
}
Loading…
Cancel
Save