Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a more cohesive message-passing system capable of handling refreshes and arbitrary events #157

Open
Foxinatel opened this issue Apr 21, 2023 · 4 comments
Assignees
Labels
significant Intended to denote large changes that Fang and Michael to undertake befor the main release

Comments

@Foxinatel
Copy link
Contributor

Foxinatel commented Apr 21, 2023

I'm mostly going to use this issue as a scratchboard for ideas I've had and new ways that we might possibly be able to achieve this.
Ideally a good message passing system:

  • Should enforce rules about types at compile-time
  • Should allow a component to send a message to another component without hard-references
@Foxinatel Foxinatel self-assigned this Apr 21, 2023
@Foxinatel
Copy link
Contributor Author

If we are to design a message-passing system that's capable of passing messages between controllers without any concept of hard-references, there's only really one way to go about that, and that's dynamically reflecting on types. (Let it be known I hate dynamic reflection with every ounce of my being)

@Foxinatel
Copy link
Contributor Author

This means that somewhere we need to store what is essentially a Map<Class<?>, Controller>, or more likely a Map<Class<?>, List<Controller>>
This is the fundamental design in the current event bus system, but leaves a giant flaw in the fact that we get dangling references.
An object should unsubscribe itself from the event bus in the situation when it's no longer accessible to any UI elements, but as far as I can tell, there's no easy way to implement this, so we'll have to consider alternatives.

@Foxinatel
Copy link
Contributor Author

One idea that I've been trying to exploit for a long time is this idea of creating a tree of controllers, at which point we can start enforcing better control flow.
If we state that each controller has exactly one parent, we can start to imagine a control flow where refreshing a parent cleanly refreshes all of it's child controllers.

@Foxinatel
Copy link
Contributor Author

In order to stop dangling references, we need to make sure that a controller unsubscribes dead (or soon-to-die) subcontrollers. This is easy if we make the assumption that every controller has a unique class, because we can just store a Map<Class<?>, Controller> inside each parent to lookup it's children by their class.
Unfortunately we have some situations where we actually use arrays of controllers, like with RemoteController, which complicates things quite a lot.
A RemoteController, for example, should be able to subscribe itself to a parent alongside other objects of class RemoteController

@InRe-Dan InRe-Dan added the significant Intended to denote large changes that Fang and Michael to undertake befor the main release label Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
significant Intended to denote large changes that Fang and Michael to undertake befor the main release
Projects
None yet
Development

No branches or pull requests

2 participants