behavior of loadResource() confusing #1200
Replies: 4 comments 2 replies
-
Nice catch. I assume that you would want the following of the SDK:
The current API is likely
Ideally, a developer (1) loads messages once and then only (2) reference messages as desired. a change in the language (3) is not exposed. |
Beta Was this translation helpful? Give feedback.
-
@samuelstroschein tbh i dont have enough experience with inlang yet to have a strong oppinion about the api/sdk, for me as develpper its only important to have clear expectations what actions result in network requests and when / how many. |
Beta Was this translation helpful? Give feedback.
-
The problem was that we
I have published a new version |
Beta Was this translation helpful? Give feedback.
-
@lucidNTR Thanks for your investigation! |
Beta Was this translation helpful? Give feedback.
-
Setup:
current main branches of inlang and example app, chrome
Description:
The example app loads resources on mouseover with loadResource(...) on the language toggle which results in a network request to the translation file.
the actual toggle of the language leads to another request to the same language file.
Problem:
the name loadResource sounds to me like the reosource is loaded, parsed and allready in memory, so this behaviour is unexpected and not clear if it is a bug or not.
Possible Solutions:
if the behavior is correct and loadResources is supposed to only prime the browser cache with the resource file, i propose changing the api name to something like prefetchResource().
if the behaviour is a not expected, we should fix reusing allready loaded resources when calling switchLanguage(...)
Beta Was this translation helpful? Give feedback.
All reactions