You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the best way to access global data initialized via ajax call?
E.g. the app wants to load localization strings from the backend lazily, depending on which language's localization strings should be fetched. Every component of the app that renders strings needs to access the localization hashmap in order to be able to render its content. This should be done without any Msg roundtrip! Ideally, it should be just as convenient as accessing a global lazy_static hashmap.
How can it be done?
The requirements are:
The localization strings are stored in a lazily initialized hashmap, it has to be initialized with the data returned from an ajax call to the backend
Every component needs to be able to access this data without a Msg handling roundtrip, ideally just like accessing a global lazy_static var.
What are the different ways that it can be done in a convenient way?
The text was updated successfully, but these errors were encountered:
If all of your components need it, sounds like you will want to kick off the request right away. Then you could have your root component show a loading screen until the fetch finishes. Once it's finished, how about you populate a mutable static hashmap which all components can access? https://doc.rust-lang.org/reference/items/static-items.html#mutable-statics
What is the best way to access global data initialized via ajax call?
E.g. the app wants to load localization strings from the backend lazily, depending on which language's localization strings should be fetched. Every component of the app that renders strings needs to access the localization hashmap in order to be able to render its content. This should be done without any Msg roundtrip! Ideally, it should be just as convenient as accessing a global lazy_static hashmap.
How can it be done?
The requirements are:
Msg
handling roundtrip, ideally just like accessing a global lazy_static var.What are the different ways that it can be done in a convenient way?
The text was updated successfully, but these errors were encountered: