{"id":13496355,"url":"https://github.com/gillchristian/remote-data-ts","last_synced_at":"2025-07-24T14:33:34.937Z","repository":{"id":33799560,"uuid":"162633627","full_name":"gillchristian/remote-data-ts","owner":"gillchristian","description":"Type to model asynchronous operations","archived":false,"fork":false,"pushed_at":"2023-06-13T16:18:25.000Z","size":398,"stargazers_count":20,"open_issues_count":3,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-15T04:25:51.012Z","etag":null,"topics":["remote-data","types","typescript"],"latest_commit_sha":null,"homepage":"https://gillchristian.github.io/remote-data-ts","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/gillchristian.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-12-20T21:34:10.000Z","updated_at":"2025-04-03T05:31:30.000Z","dependencies_parsed_at":"2024-01-16T09:54:23.551Z","dependency_job_id":"d72a6686-9a6e-4b98-a928-2b46e2c4bc9c","html_url":"https://github.com/gillchristian/remote-data-ts","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/gillchristian/remote-data-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillchristian%2Fremote-data-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillchristian%2Fremote-data-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillchristian%2Fremote-data-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillchristian%2Fremote-data-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gillchristian","download_url":"https://codeload.github.com/gillchristian/remote-data-ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillchristian%2Fremote-data-ts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266855979,"owners_count":23995594,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"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":["remote-data","types","typescript"],"created_at":"2024-07-31T19:01:46.663Z","updated_at":"2025-07-24T14:33:34.169Z","avatar_url":"https://github.com/gillchristian.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eremote-data-ts\u003c/h1\u003e\n\n[![Test](https://github.com/gillchristian/remote-data-ts/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/gillchristian/remote-data-ts/actions/workflows/build.yml)\n\nType to model asynchronous operations data and the statuses it can be in.\n\nInspired by Elm's\n[krisajenkins/remotedata](https://package.elm-lang.org/packages/krisajenkins/remotedata/latest/RemoteData).\n\n## Install\n\n```\nyarn add fp-ts remote-data-ts\n\nnpm i fp-ts remote-data-ts\n```\n\nNote `fp-ts` is a peer dependency.\n\n## Usage\n\nRemoteData defines the statuses a fetched data can be:\n\n```ts\ntype RemoteData\u003cE, A\u003e = NotAsked | Loading | Success\u003cA\u003e | Failure\u003cE\u003e;\n```\n\n```tsx\nimport React, { useState, useEffect, SFC } from 'react';\nimport { render } from 'react-dom';\nimport { pipe } from 'fp-ts/function';\nimport * as RD from 'remote-data-ts';\n\nimport './styles.css';\n\ninterface ArticleProps {\n  title: string;\n  body: string;\n}\n\nconst Article: SFC\u003cArticleProps\u003e = ({ title, body }) =\u003e (\n  \u003c\u003e\n    \u003ch1\u003e{title}\u003c/h1\u003e\n    \u003cp\u003e{body}\u003c/p\u003e\n  \u003c/\u003e\n);\n\ntype State = RD.RemoteData\u003cArticleProps, string\u003e;\n\nconst App: SFC = () =\u003e {\n  const [state, setState] = useState(RD.notAsked);\n\n  useEffect(() =\u003e {\n    setState(RD.loading);\n\n    fetch('https://jsonplaceholder.typicode.com/posts/1')\n      .then((res) =\u003e\n        res.ok ? res.json() : new Error(`${res.status} ${res.statusText}`),\n      )\n      .then((article: ArticleProps) =\u003e {\n        setState(RD.success(article));\n      })\n      .catch((err: Error) =\u003e {\n        setState(RD.failure(err.message));\n      });\n  }, []);\n\n  return (\n    \u003cdiv className=\"App\"\u003e\n      {pipe(\n        state,\n        RD.match({\n          notAsked: () =\u003e null,\n          loading: () =\u003e \u003cdiv\u003e... loading ...\u003c/div\u003e,\n          success: (article) =\u003e \u003cArticle {...article} /\u003e,\n          error: (msg) =\u003e (\n            \u003cdiv className=\"red\"\u003eFailed to load article: {msg}\u003c/div\u003e\n          ),\n        }),\n      )}\n    \u003c/div\u003e\n  );\n};\n\nrender(\u003cApp /\u003e, document.getElementById('root'));\n```\n\nSee other examples in [examples/index.ts](/examples/index.ts).\n\n## License\n\n[MIT](https://github.com/gillchristian/remote-data-ts/blob/master/LICENSE) ©\n2022 Christian Gill\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgillchristian%2Fremote-data-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgillchristian%2Fremote-data-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgillchristian%2Fremote-data-ts/lists"}