{"id":21619107,"url":"https://github.com/bannzai/async","last_synced_at":"2025-03-17T16:12:48.763Z","repository":{"id":65002882,"uuid":"574959864","full_name":"bannzai/Async","owner":"bannzai","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-06T03:47:44.000Z","size":89,"stargazers_count":66,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-10T16:01:39.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","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/bannzai.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}},"created_at":"2022-12-06T13:00:49.000Z","updated_at":"2025-03-04T07:43:44.000Z","dependencies_parsed_at":"2024-02-15T05:39:30.790Z","dependency_job_id":null,"html_url":"https://github.com/bannzai/Async","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FAsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FAsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FAsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FAsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bannzai","download_url":"https://codeload.github.com/bannzai/Async/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066189,"owners_count":20392406,"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-11-24T23:07:56.087Z","updated_at":"2025-03-17T16:12:48.738Z","avatar_url":"https://github.com/bannzai.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Async\n**Async** is a easily handle async state and simple state management library for `SwiftUI`.\n\n## Features\nIn the **Async** philosophy the asynchronous state is seen as divided into three parts. One is `success`. The other is `failure`. Finally, the `loading` state before execute async function.\nAsync is provided two way for async state management named `@Async` property wrapper and `AsyncView`. These two structures are used separately and simplify the division of the three states. They essentially have the same function, but can be used in different usecase. \n\n## Example\n\n1. Use `@Async`.\nFirst, Define `@Async` with state type. The code example below refers to a `String`.\nNext, `async` call as function with asynchronous function. The code example below refers to a `run` function and can chain to access async state for switching decide view for each async state.\nThis method also allows access to `async.state` and the use of `alert(isPresented:error:actions)` modifier with `async.error`. See `Example` for more information.\n\n```swift\nstruct ContentView: View {\n  @Async\u003cString, Error\u003e var async\n\n  var body: some View {\n    switch async(run).state {\n    case .success(let value):\n      Text(\"\\(value)\")\n    case .failure(let error):\n      Text(error.localizedDescription)\n    case .loading:\n      ProgressView()\n    }\n  }\n}\n```\n\n2. Use `AsyncView`.\nPass async function directly to `AsyncView` initializer, and define three states view via `when`.\n\n```swift\nstruct ContentView: View {\n  var body: some View {\n    AsyncView(run, when: (\n      success: { Text(\"\\($0)\") },\n      failure: { Text($0.localizedDescription) },\n      loading: { ProgressView() }\n    ))\n  }\n}\n```\n\n## LICENSE\n**Async** is released under the MIT license. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbannzai%2Fasync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbannzai%2Fasync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbannzai%2Fasync/lists"}