Rename window::closings to window::close_events

This commit is contained in:
Héctor Ramón Jiménez 2024-06-16 20:15:55 +02:00
parent ad2e4c535a
commit b5c5a016c4
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 28 additions and 6 deletions

View file

@ -150,7 +150,7 @@ impl multi_window::Application for Example {
}
fn subscription(&self) -> Subscription<Self::Message> {
window::closings().map(Message::WindowClosed)
window::close_events().map(Message::WindowClosed)
}
}

View file

@ -155,10 +155,21 @@ pub fn frames() -> Subscription<Instant> {
})
}
/// Subscribes to all window close requests of the running application.
pub fn close_requests() -> Subscription<Id> {
/// Subscribes to all window events of the running application.
pub fn events() -> Subscription<(Id, Event)> {
event::listen_with(|event, _status, id| {
if let crate::core::Event::Window(Event::CloseRequested) = event {
if let crate::core::Event::Window(event) = event {
Some((id, event))
} else {
None
}
})
}
/// Subscribes to all [`Event::Closed`] occurrences in the running application.
pub fn open_events() -> Subscription<Id> {
event::listen_with(|event, _status, id| {
if let crate::core::Event::Window(Event::Closed) = event {
Some(id)
} else {
None
@ -166,8 +177,8 @@ pub fn close_requests() -> Subscription<Id> {
})
}
/// Subscribes to all window closings of the running application.
pub fn closings() -> Subscription<Id> {
/// Subscribes to all [`Event::Closed`] occurrences in the running application.
pub fn close_events() -> Subscription<Id> {
event::listen_with(|event, _status, id| {
if let crate::core::Event::Window(Event::Closed) = event {
Some(id)
@ -177,6 +188,17 @@ pub fn closings() -> Subscription<Id> {
})
}
/// Subscribes to all [`Event::CloseRequested`] occurences in the running application.
pub fn close_requests() -> Subscription<Id> {
event::listen_with(|event, _status, id| {
if let crate::core::Event::Window(Event::CloseRequested) = event {
Some(id)
} else {
None
}
})
}
/// Opens a new window with the given [`Settings`]; producing the [`Id`]
/// of the new window on completion.
pub fn open(settings: Settings) -> Task<Id> {