update message passing doc

This commit is contained in:
scawful
2024-08-15 23:19:59 -04:00
parent 7af5209aeb
commit 424ecfd4d2

View File

@@ -2,7 +2,9 @@
## Overview
yaze includes a message passing and notification system as part of its core library. This system allows different parts of your application to communicate through messages, enabling a loosely coupled architecture that enhances modularity, maintainability, and scalability. The system supports advanced features such as message filtering, dynamic method binding, swizzling, and reflection, making it highly dynamic and adaptable for complex applications, including those requiring plugin or extension systems.
yaze includes a message passing and notification system as part of its core library. Supports message filtering, dynamic method binding, swizzling, and reflection. This message system was inspired by Objective-C and Cocoa's message passing system. It aims to overcome some of the difficulties with handling events in ImGui.
This system is currently in development and most of the content here was generated using ChatGPT to help me organize my thoughts. I will be updating this document as I continue to develop the system.
### Key Components
@@ -31,6 +33,8 @@ yaze::app::core::AsyncMessageDispatcher async_dispatcher;
async_dispatcher.Start();
```
The EditorManager in the main yaze app will have a MessageDispatcher instance which can be injected into the various Editor components. This will allow the components to communicate with each other without needing to know about each other.
#### 2. **Registering Listeners**
Components that need to listen for messages must implement the `IMessageListener` interface and register themselves with the dispatcher.
@@ -159,7 +163,3 @@ To broadcast a notification, create a `Notification` object and post it through
yaze::app::core::Notification notification("MyNotificationType", this, some_payload);
notification_center.PostNotification(notification);
```
### Extending the System
This system is designed to be highly extensible. You can create plugins that register their own message handlers, protocols, and dynamic behaviors. Additionally, the use of method swizzling and reflection allows for runtime changes to object behavior and properties, making this system ideal for applications that require a high degree of flexibility and modularity.