{"id":16511217,"url":"https://github.com/danog/asyncconstruct","last_synced_at":"2026-04-15T20:06:10.681Z","repository":{"id":56962178,"uuid":"284039368","full_name":"danog/asyncConstruct","owner":"danog","description":"Async class constructor and wakeup functions for AMPHP.","archived":false,"fork":false,"pushed_at":"2020-07-31T13:44:45.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-12T20:13:14.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/danog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"danog"}},"created_at":"2020-07-31T13:09:58.000Z","updated_at":"2020-07-31T13:44:47.000Z","dependencies_parsed_at":"2022-08-21T10:20:46.346Z","dependency_job_id":null,"html_url":"https://github.com/danog/asyncConstruct","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2FasyncConstruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2FasyncConstruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2FasyncConstruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2FasyncConstruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danog","download_url":"https://codeload.github.com/danog/asyncConstruct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241476435,"owners_count":19968916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-11T15:59:21.955Z","updated_at":"2026-04-15T20:06:10.635Z","avatar_url":"https://github.com/danog.png","language":"PHP","funding_links":["https://github.com/sponsors/danog"],"categories":[],"sub_categories":[],"readme":"# AsyncConstruct\n\n![Build status](https://github.com/danog/asyncConstruct/workflows/build/badge.svg)\n[![codecov](https://codecov.io/gh/danog/asyncConstruct/branch/master/graph/badge.svg)](https://codecov.io/gh/danog/asyncConstruct)\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n`danog/asyncConstruct` provides async class constructor and wakeup functions for AMPHP.  \n\n## Installation\n\n```bash\ncomposer require danog/async-construct\n```\n\n## API\n\n* Async\n  * [AsyncConstruct](#AsyncConstruct)\n  * [AsyncWakeup](#AsyncWakeup)\n* Blocking\n  * [BlockingConstruct](#BlockingConstruct)\n  * [BlockingWakeup](#BlockingWakeup)\n\n### AsyncConstruct\n\n[Example](https://github.com/danog/asyncConstruct/blob/master/examples/async.php)  \n\nSimply `use` this trait in your class, and define a `__construct_async` async method.  \nThe trait will automatically run the async method on construction, and expose a set of APIs to wait on the result of the constructor for initialization.  \n\n#### `init()`\n\nWill blockingly wait for execution of the async constructor, returning its return value.  \n\n#### `initAsynchronously()`\n\nWill return a promise that, when `yield`ed, will wait for and return the return value of the constructor.\n\n#### `inited()`\n\nReturns a boolean, indicating whether the class was initialized or not.  \n\n\n### BlockingConstruct\n\n[Example](https://github.com/danog/asyncConstruct/blob/master/examples/blocking.php)  \n\nExactly like [AsyncConstruct](#AsyncConstruct), except that the blocking `init()` function will be automatically called on construction.  \n\n### AsyncWakeup\n\n[Example](https://github.com/danog/asyncConstruct/blob/master/examples/asyncWakeup.php)  \n\nSimply `use` this trait in your class, and define a `__wakeup_async` async method.  \nThe trait will automatically run the async method on deserialization, and expose a set of APIs to wait on the result of the wakeup function for re-initialization.  \n\n#### `wakeup()`\n\nWill blockingly wait for execution of the async wakeup function, returning its return value.  \n\n#### `wakeupAsynchronously()`\n\nWill return a promise that, when `yield`ed, will wait for and return the return value of the wakeup function.\n\n#### `wokenUp()`\n\nReturns a boolean, indicating whether the class was initialized or not.  \n\n\n### BlockingWakeup\n\n[Example](https://github.com/danog/asyncConstruct/blob/master/examples/blockingWakeup.php)  \n\nExactly like [AsyncWakeup](#AsyncWakeup), except that the blocking `wakeup()` function will be automatically called on wakeup.  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Fasyncconstruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanog%2Fasyncconstruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Fasyncconstruct/lists"}