lifecycle update

This commit is contained in:
Jorijn van der Graaf 2025-11-14 18:40:13 +01:00
commit 0b7a43efbd
14 changed files with 950 additions and 490 deletions

View file

@ -1,17 +1,16 @@
import Crafter.CppDOM;
import std;
using namespace Crafter;
using namespace Crafter::CppDOMBindings;
HtmlElementPtr body("body", "<h1>Fetch Example</h1><p>Testing HTTP requests...</p>");
int main(){
void* body = GetElementById("body");
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Testing HTTP requests...</p>");
Fetch("https://httpbin.org/get", [body](std::string result){
Fetch("https://httpbin.org/get", [](std::string result){
if (!result.empty()) {
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Response: " + result + "</p>");
body.SetInnerHTML("<h1>Fetch Example</h1><p>Response: " + result + "</p>");
} else {
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Failed to fetch data</p>");
body.SetInnerHTML("<h1>Fetch Example</h1><p>Failed to fetch data</p>");
}
FreeJs(body);
});
}