I want the front end to use the returned Channel to stop the download, but there is no send method on the Channel.
#[tauri::command]
pub async fn download_multi(
options: DownloadOptions,
tx: Channel<Event>,
) -> Result<Channel<()>, Error> {
// Downloading ...
let abort_handle = handle.abort_handle();
let stop_channel: Channel<()> = Channel::new(move |_| {
println!("stop download");
abort_handle.abort();
Ok(())
});
Ok(stop_channel)
}
declare class Channel<T = unknown> {
#private;
/** The callback id returned from {@linkcode transformCallback} */
id: number;
constructor(onmessage?: (response: T) => void);
private cleanupCallback;
set onmessage(handler: (response: T) => void);
get onmessage(): (response: T) => void;
[SERIALIZE_TO_IPC_FN](): string;
toJSON(): string;
}