{"id":15351228,"url":"https://github.com/adufilie/mobxpromise","last_synced_at":"2025-04-15T04:21:07.376Z","repository":{"id":57299721,"uuid":"83637302","full_name":"adufilie/MobxPromise","owner":"adufilie","description":"Provides an observable interface for a computed promise.","archived":false,"fork":false,"pushed_at":"2022-10-24T21:42:49.000Z","size":337,"stargazers_count":3,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T15:48:25.221Z","etag":null,"topics":["async","computed","mobx","promise"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/adufilie.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}},"created_at":"2017-03-02T05:16:11.000Z","updated_at":"2021-05-07T08:47:19.000Z","dependencies_parsed_at":"2022-08-26T20:24:44.384Z","dependency_job_id":null,"html_url":"https://github.com/adufilie/MobxPromise","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adufilie%2FMobxPromise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adufilie%2FMobxPromise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adufilie%2FMobxPromise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adufilie%2FMobxPromise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adufilie","download_url":"https://codeload.github.com/adufilie/MobxPromise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249004367,"owners_count":21196863,"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":["async","computed","mobx","promise"],"created_at":"2024-10-01T12:02:32.978Z","updated_at":"2025-04-15T04:21:07.335Z","avatar_url":"https://github.com/adufilie.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MobxPromise\n\nProvides\n[observable](https://mobx.js.org/refguide/api.html) \nstatus and results from \n[computed](https://mobx.js.org/refguide/computed-decorator.html) \npromises to make it easy to render\n[MobX observer components](https://mobx.js.org/refguide/observer-component.html)\nfrom changing, asynchronous data with\n[mobx-react](https://github.com/mobxjs/mobx-react).\n\nA MobxPromise (MP) is integrated into an application by referencing its\ncomputed properties (`status`, `result`, ...) in the render method of an\n[observer component](https://mobx.js.org/refguide/observer-component.html).\nThanks to \n[mobx-react](https://github.com/mobxjs/mobx-react), \nthe component's render function will be re-invoked whenever the properties \nof the referenced MP change. The status of the MP and its resulting data will\nthus be reflected as a product of reference, with no other wiring necessary.\n\nHow does this happen? A reference to any property of the MP invokes that property's\n[@computed](https://mobx.js.org/refguide/computed-decorator.html)\ngetter. The getter first checks the `status` of any MP in the `await` collection\n(and this causes the same process to occur inside these children). If any awaited promises are\nnot complete (i.e. `status` is `\"error\"` or `\"pending\"`) then that is assumed to be the status \nof the awaiting MP. If all awaited promises are complete, then the MP accesses its\n[@computed](https://mobx.js.org/refguide/computed-decorator.html)\npromise using the provided `invoke` method.\n\nWhen the promise resolves, the MP's `status` is set to `\"complete\"` unless the promise\nhas become stale or members of the `await` collection no longer have a `status` of `\"complete\"`.\nThe computed promise becomes stale when observable dependencies of the `invoke` function have\nchanged. Promises which become stale before being resolved will never set the status or result \nof the MP and will thus have no influence on the application. Thanks to\n[MobX](https://github.com/mobxjs/mobx),\nthe `invoke` method will only be called again when its referenced observables have changed.\n\n\n## Acknowledgements\n\nThanks to [@alisman](https://github.com/alisman) for writing a big chunk of this readme.\n\nThanks to the [@cBioPortal](https://github.com/cBioPortal) team for feedback which helped shape this little utility class.\n\nThis project was set up using [TypeScript library starter](https://github.com/alexjoverm/typescript-library-starter).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadufilie%2Fmobxpromise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadufilie%2Fmobxpromise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadufilie%2Fmobxpromise/lists"}