Events
Resource manager is able to notify its subscribers about specific events of resources. There are four kinds of resource events:
Loaded
- occurs when a resource was fully loaded without any errors.Reloaded
- occurs when a resource was already fully loaded, but was reloaded by an explicit request.Added
- occurs when a resource was just added to the resource manager. This event is fired right after a resource was requested from the manager.Removed
- occurs when a resource was removed from the resource manager. This event is fired when the resource manager removes and unloads an unused resource.
To subscribe for resource events use the event broadcaster:
#![allow(unused)] fn main() { pub fn subscribe_to_events(resource_manager: &ResourceManager) { let (sender, receiver) = channel(); resource_manager.state().event_broadcaster.add(sender); while let Ok(event) = receiver.try_recv() { match event { ResourceEvent::Loaded(_) => {} ResourceEvent::Reloaded(_) => {} ResourceEvent::Added(_) => {} ResourceEvent::Removed(_) => {} } } } }