{"id":21325791,"url":"https://github.com/flaviotordini/promises","last_synced_at":"2026-05-16T23:16:19.365Z","repository":{"id":93233313,"uuid":"377846233","full_name":"flaviotordini/promises","owner":"flaviotordini","description":"Javascript-style Promise implementation for Qt","archived":false,"fork":false,"pushed_at":"2024-05-14T06:59:47.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T23:43:42.870Z","etag":null,"topics":["async","asynchronous","asynchronous-programming","promise","promises","qt","qt6"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flaviotordini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-17T13:47:58.000Z","updated_at":"2024-05-14T06:59:50.000Z","dependencies_parsed_at":"2025-01-22T12:28:50.434Z","dependency_job_id":"a115000f-4129-4693-9a85-6e0e1500783f","html_url":"https://github.com/flaviotordini/promises","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flaviotordini/promises","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fpromises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fpromises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fpromises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fpromises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flaviotordini","download_url":"https://codeload.github.com/flaviotordini/promises/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fpromises/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33121899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"ssl_error","status_checked_at":"2026-05-16T18:38:29.903Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","asynchronous","asynchronous-programming","promise","promises","qt","qt6"],"created_at":"2024-11-21T21:07:27.470Z","updated_at":"2026-05-16T23:16:19.336Z","avatar_url":"https://github.com/flaviotordini.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Qt Promises\n\nA very simple Javascript-style Promise implementation for Qt. The main idea is to use QObject features (i.e. signal and slots, deleteLater) to implement promises.\n\nI wrote this Promise implementation in Qt 5 times. I'm not sure whether Qt 6 has something comparable in terms of simplicity and lightness. Anyway, it works great in Qt 6 too and I'm using it in my apps at https://flavio.tordini.org\n\nIn the Qt world a signal is emitted by an object instance. Sometimes that's exactly what's needed, like in the Observer design pattern (aka Publisher/Subscriber). In other cases the asynchronous response should be bound to a specific function call and having an instance-wide signal can be a cause of concurrency problems. Using promises to return async data from a function is a better solution: in Qt terms, it basically creates a temporary object with its own signal connection which is not shared with other users of a function.\n\n## Example usage\n\nThe main class is Promise. It is template-based. Use it like this:\n\n```c++\nPromise\u003cQString\u003e \u0026myAsyncFunction() {\n  auto promise = new Promise\u003cQString\u003e(this);\n\n  // any asynchronous work you might have to do:\n  connect(myObj, \u0026MyObject::finished, this, [promise](auto result) {\n    if (myObj.hasError()) promise-\u003ereject(myObj.errorMessage());\n    else promise-\u003eresolve(result);\n  });\n  myObj.doSomething();\n\n  return *promise;\n}\n\nmyAsyncFunction().then([](auto result) {\n  qDebug() \u003c\u003c \"Success!\" \u003c\u003c result;\n}).onFailed([](auto errorMessage)) {\n  qWarning() \u003c\u003c \"Error!\" \u003c\u003c errorMessage;\n}).finally([] {\n  // optionally do something in both cases\n});\n```\n\n## EmptyPromise\n\n`EmptyPromise` can be used when there is no data as the result of the async operation.\n\n## VariantPromise\n\n`VariantPromise` is not template-based but QVariant-based. It can be useful when the data result is a QVariant or any QVariant-supported data type, especially if there is a need to avoid templates for any reason.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviotordini%2Fpromises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflaviotordini%2Fpromises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviotordini%2Fpromises/lists"}