Boscop / Boscop/web-view

how to create handler?

Open
#324 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2k
Forks
179
PR merge metrics
No merged PRs in 30d

Description

I used web-view,, want to show the small window with notice words in it, and automatically disappear after 2 seconds.
so create the handler and use it to exit the window, but how to create the handler?

web_view: 0.7.3

```
use web_view::*;

fn main() {
let html = "Hello world!";

let handle = web_view::Handle::current().unwrap();

std::thread::spawn(move || {
std::thread::sleep(std::time::Duration::from_secs(2));
handle.dispatch(move |webview| {
webview.terminate();
Ok(())
}).unwrap();
});

web_view::builder()
.title("")
.content(Content::Html(html))
.size(250, 20)
.resizable(false)
.frameless(true)
.user_data(handle.clone())
.invoke_handler(|_webview, _arg| Ok(()))
.run()
.unwrap();
}
```

how to create the handler?
let handle = web_view::Handle::current().unwrap(); # it's wrong way.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the web_view 0.7.3 API around Handle::current, dispatch, and the builder example shown in the issue. Document the correct way to obtain a handler for terminating the window after two seconds, and verify the example's behavior with the provided sample.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.