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

Best practice for global singleton ViewMode? #2

Open
eefan000 opened this issue Jul 13, 2024 · 14 comments
Open

Best practice for global singleton ViewMode? #2

eefan000 opened this issue Jul 13, 2024 · 14 comments

Comments

@eefan000
Copy link

No description provided.

@grashaar
Copy link
Collaborator

Could you please give out more information on the usecase?

@eefan000
Copy link
Author

Could you please give out more information on the usecase?

https://dev.epicgames.com/documentation/en-us/unreal-engine/umg-viewmodel#globalviewmodelcollection

@eefan000
Copy link
Author

eefan000 commented Jul 14, 2024

In the game, there are many global ViewModels, such as account data, current level data, tasks, and so on.

For these global ViewModels, it would be much more convenient if they could be directly referenced when binding data in the UI, without the need to manually install the ViewModel through code.

@grashaar
Copy link
Collaborator

Truthfully the current implementation only supports binding through setting up components on GameObject beforehand. Binding through code has not been supported very well; many autormated mechanism is currently missing. I'm afraid it might take a while before I can work on these missing pieces.

@eefan000
Copy link
Author

Can we refer to UE5 MVVM and add a global binding context option in the binding context?
Register a global VM in the code?
It doesn't seem like a big change, I'll try making it myself later

@grashaar
Copy link
Collaborator

Feel free to fork this repo and experiment however you please. Btw, if I might have a word of caution, a global strategy should be designed carefully and fully decoupled from the core functionality. Especially singletons should only be an extension to the core.

@eefan000
Copy link
Author

eefan000 commented Aug 21, 2024

image
image
I have a preliminary implementation now, and it looks like this when used

SVN difference.txt

@grashaar Do you have any evaluation of this simple implementation

@grashaar
Copy link
Collaborator

I really don't like the idea of coupling MonoBindingContext with detailed implementation on how to get the ObservableObject reference. The global object should be injected into MonoBindingContext via a different component.

@eefan000
Copy link
Author

eefan000 commented Aug 29, 2024

I really don't like the idea of coupling MonoBindingContext with detailed implementation on how to get the ObservableObject reference. The global object should be injected into MonoBindingContext via a different component.

The main purpose is to reduce the number of operational steps. If it is an independent component, it is necessary to synchronize some settings to MonoBindContext to ensure that MonoBinder can display relevant information normally in the future

I expect that in most cases in my project, it will be GlobalObject, which will result in the need for many additional GlobalObject components

@grashaar
Copy link
Collaborator

I think what is missing from the current MonoBindingContext is the ability to provide any type information for the binders. Type information should be decoupled from runtime instances of ObservableObject.

@eefan000
Copy link
Author

Indeed, I think it's even possible to consider selecting the target VM type and target property path directly on each attribute of the binder.

The multiple VM instances required by the binder are installed at runtime by external features such as MonoBindContext, Enhanced GridBinding, or GlobalObject Components

@grashaar
Copy link
Collaborator

grashaar commented Aug 29, 2024

Then we need a powerful editor toolset to govern the target types and its property paths so we can notify the user if any type is missing or some property paths no longer exist. Because the target types will be scattered everywhere across the View prefab.

@eefan000
Copy link
Author

Consider directly based on Odin, which makes it easier to scale and reduces workload.

I don't think anyone wouldn't need Odin🤔

@grashaar
Copy link
Collaborator

Odin is a paid software, it can't be a dependency for an open source library such as this. On the other hand, I don't think Odin can help much instead of providing premade utitlities to work with types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants