Replies: 3 comments 2 replies
-
Hey there, The library doesn't really target client-server setups, at least we don't make any special considerations for async operations. And the short answer to your question is "no", we don't try to load the texture again. There is a longer answer if you're willing to try some workarounds to get the behavior you want. At least, here is an (untested) idea. First, after you have actually fetched the image file, call Or, probably a more robust approach: Use a placeholder texture file, and then replace that with the correct source file once the image has loaded. I hope you're able to work it out. Although keep in mind that this isn't really a target use case for the library. The async part ideally would be implemented on your side, and then RmlUi should be treated as a "synced" interface. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response Michael. In my use case, I won't necessarily know which document is loading the element. Nor will I know the dimensions of the texture before it is loaded / reloaded. If I understand correctly, there is not currently logic in place to dirty the layout if the dimensions of the image have changed? In |
Beta Was this translation helpful? Give feedback.
-
I'll leave an update here, just in case you were wondering. I was able to achieve async loading of documents in what is probably a very jank solution. I made by own FileInterface that used my server-retrieved assets (stored as strings). If the file was not yet retrieved, it threw the filename which I then catch in my own document factory which tells me what I need to request from the server. This is also done using v8 bindings. Here is a code snippet to show how it works. uiContext.loadDocument("userlogin.rml")
.then(doc => {
let loginBtn = doc.getElementById("loginButton");
let onClick = (e) => {
print("btn clicked from js with event type: " + e.getType())
};
loginBtn.addEventListener("click", onClick, false)
doc.show();
}); I have not tackled the reloading of images yet, but I suspect I may fork the repo and dirty the layout each time an image is loaded. That sounds inefficient, but it may suffice for my use case. |
Beta Was this translation helpful? Give feedback.
-
Hi,
My project involved a client-server architecture. This means that any assets that the client may need must be served from the server. For that reason, I need to ensure that I can load files asynchronously. I already saw Issue 131 in which something similar was addressed. However, since I cannot promise that a file will be loaded by the time Rml needs it, I'd like to know whether it will re-attempt to load it on the next cycle if it was unsuccessful in the previous attempts.
I suppose my main question here is whether the
LoadTexture
method will be called again for the same asset even if it returned false (failed) the first time around.Beta Was this translation helpful? Give feedback.
All reactions