{"id":20113836,"url":"https://github.com/adalbertuschris/async-await-rx","last_synced_at":"2026-05-19T07:09:52.279Z","repository":{"id":144663098,"uuid":"543091274","full_name":"adalbertuschris/async-await-rx","owner":"adalbertuschris","description":"Extension for rxjs library","archived":false,"fork":false,"pushed_at":"2022-10-05T19:43:07.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T16:30:02.614Z","etag":null,"topics":["angular","async","async-await","observable","rxjs","typescript"],"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/adalbertuschris.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}},"created_at":"2022-09-29T11:44:20.000Z","updated_at":"2023-10-05T19:20:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"dfcaf8c0-e69f-46a3-ae24-d118ddc38ea4","html_url":"https://github.com/adalbertuschris/async-await-rx","commit_stats":null,"previous_names":["adalbertuschris/async-await-rx","async-await-rx/core"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adalbertuschris/async-await-rx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adalbertuschris%2Fasync-await-rx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adalbertuschris%2Fasync-await-rx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adalbertuschris%2Fasync-await-rx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adalbertuschris%2Fasync-await-rx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adalbertuschris","download_url":"https://codeload.github.com/adalbertuschris/async-await-rx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adalbertuschris%2Fasync-await-rx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33205678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"online","status_checked_at":"2026-05-19T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["angular","async","async-await","observable","rxjs","typescript"],"created_at":"2024-11-13T18:26:10.730Z","updated_at":"2026-05-19T07:09:52.232Z","avatar_url":"https://github.com/adalbertuschris.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Extension for rxjs library\n\n## Table of Contents\n\n* [Installation](#installation)\n* [Usage](#usage)\n* [Methods](#methods)\n* [Operators](#operators)\n\n## Installation\n\nFirst you need to install the npm module:\n\n```sh\nnpm install async-await-rx --save\n```\n\nIn plain rxjs we have a lot of operators and we can do the same actions in different ways.\nOften we do repeatable actions such as fetching data parallely, one by one etc. and every time we have to build it with many operators. This extension can simplify code by introducing only few operators for repeatable actions. Thanks to this extension code is more clear and we can focus on action to do, not which operator we should choose.\n\nThis extension can be useful when: \n- you need data from each actions,\n- you want to call actions parallely or one by one and you want to wait on result - awaitAll\n- you want to define dynamic actions - asyncPipeFrom\n\n\n## Usage\n\nStackBlitz examples (https://stackblitz.com/edit/rxjs-uwwzxh?devtoolsheight=100\u0026file=index.ts)\n\n\nComparizon with plain rxjs\n\ncode with async pipe extension\n\n```ts\nasyncPipe(\n  awaitAction(() =\u003e action1()),\n  awaitAll(() =\u003e [action2_1(), action2_2(), action2_3(), action2_4()]),\n  awaitAction(() =\u003e action3()),\n  action((value, index, [_, items]) =\u003e\n    console.log({ value, items /* data[1] */ }) // { 'action3', ['action2_1', 'action2_2', 'action2_3', 'action2_4']}\n  ),\n  awaitAction((value) =\u003e action4(value))\n)\n  .pipe(\n    takeUntil(cancel$),\n    finalize(() =\u003e (isLoading = false))\n  )\n  // Async pipe return value from last action and data from each action. It is array.\n  // we can use destructurization for example: [value, [action1Val, action2Val, action3Val]]\n  // first item is value from last action and the second is data from all actions\n  .subscribe(([value, [val1, val2, val3]]) =\u003e {\n    console.log(val1); // Display value from 1st action\n    console.log(val2); // Display items from 2nd action\n    console.log(val3); // Display items from 3rd action\n  });\n```\n\ncode without extension (in plain rxjs)\n\n```ts\naction1()\n  .pipe(\n    switchMap((data) =\u003e\n      combineLatest([action2_1(), action2_2(), action2_3(), action2_4()]).pipe(\n        map((items) =\u003e [data, items])\n      )\n    ),\n    switchMap((data) =\u003e action3().pipe(map((value) =\u003e [...data, value]))),\n    tap(([_, items, value]) =\u003e console.log({ value, items })),\n    switchMap((data) =\u003e\n      action4(data[2]).pipe(map((value) =\u003e [...data, value]))\n    ),\n    takeUntil(cancel$),\n    finalize(() =\u003e (isLoading = false))\n  )\n  .subscribe(([val1, val2, val3]) =\u003e {\n    console.log(val1); // Display value from 1st action\n    console.log(val2); // Display items from 2nd action\n    console.log(val3); // Display items from 3rd action\n  });\n```\n\n## Methods\n* asyncPipe\n\nIt takes list of operators as params and return Observable.\nasyncPipe return array where first item is value from last action and the second is data from all actions.\nIt is array to handle data in easier way (we can use destructurization for example: [value, [action1Val, action2Val, action3Val]])\n\nExample\n\n```ts\nasyncPipe(\n  awaitAction(() =\u003e action1()),\n  awaitAction(() =\u003e action2()),\n  awaitAction(() =\u003e action3())\n)\n  .pipe(\n    finalize(() =\u003e (console.log('finalize')))\n  )\n  .subscribe(([value, [val1, val2, val3]]) =\u003e {\n    console.log(val1); // action1\n  });\n```\n\n* asyncPipeFrom (factory)\n\nIt takes list of functions as params (it convert each function to awaitAction) and return Observable\n\nExample 1\n\n```ts\n    const something = 5;\n    const actions: any[] = [() =\u003e action1()];\n\n    if (something === 1) {\n      actions.push((value: string) =\u003e action2(value));\n    } else {\n      actions.push((value: string) =\u003e action3(value));\n    }\n\n    asyncPipeFrom(actions).subscribe(([_, data]) =\u003e { console.log(data) }); // [action1, action3]\n```\n\nExample 2\n\n```ts\nasyncPipe(\n  awaitAction(() =\u003e asyncPipeFrom(actions)),\n  awaitAction(() =\u003e action2())\n)\n  .pipe(\n    finalize(() =\u003e (console.log('finalize')))\n  )\n  .subscribe(([value, [val1, val2]]) =\u003e {\n    console.log(val1);\n  });\n```\n\n* omit\n\nIt takes Observable and condition as inputs. Condition determine that observable should be subscribed or should be omited.\nWhen we will use omit in awaitAction and condition is met then action will be omitted (it won't be put in the asyncPipe result)\n\nExample \n\n```ts\nconst something = 5;\n\nasyncPipe(\n    awaitAll(() =\u003e [\n        omit(action1(), something == 5), // this action will be omitted, because condition is met\n        action2(),\n    ]),\n    awaitAction(() =\u003e omit(action3(), something == 5)), // this action will be omitted, because condition is met\n    action((value) =\u003e console.log(value)), // [action2]\n    awaitAction(() =\u003e action4())\n).subscribe(([_, data]) =\u003e console.log(data)); // [[action2], action4]\n```\n\n### Operators\nEach operator takes project method as input with structure\n(value, index, data) =\u003e type\nvalue - value from previous action\nindex - value index\ndata - array with values from each action\ntype - returned type\n\n* action - (value, index, data) =\u003e void\nThis acton has no impact on asyncPipe result. Used to perform side-effects.\n\n* awaitAction - (value, index, data) =\u003e Observable\u003cany\u003e\nAction will be completed when observable have fulfilled.\n\n* awaitAll - (value, index, data) =\u003e Observable\u003cany\u003e[], strategy: AwaitAllStrategy\nAction will be completed when all of the observables have fulfilled. \nIt breaks immediately upon any of the observables throwing an error.\n\nAs second param it determine execution strategy: \nAwaitAllStrategy:\n * parallel (default) - actions are processing parallel\n * oneByOne - actions are processing one by one","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadalbertuschris%2Fasync-await-rx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadalbertuschris%2Fasync-await-rx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadalbertuschris%2Fasync-await-rx/lists"}