{"id":22385423,"url":"https://github.com/pr1mer-tech/gravity","last_synced_at":"2025-07-31T04:33:14.168Z","repository":{"id":79340921,"uuid":"354642344","full_name":"pr1mer-tech/Gravity","owner":"pr1mer-tech","description":"Gravity is a SwiftUI library for remote data fetching. Inspired by Vercel's SWR","archived":false,"fork":false,"pushed_at":"2024-11-25T04:30:41.000Z","size":879,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T20:13:09.127Z","etag":null,"topics":["hacktoberfest","network","swift","swiftui"],"latest_commit_sha":null,"homepage":"https://gravity.pr1mer.tech","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pr1mer-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2021-04-04T20:40:30.000Z","updated_at":"2025-02-16T02:37:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"485b8ea5-062b-4dd5-ac74-0172676da1ae","html_url":"https://github.com/pr1mer-tech/Gravity","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pr1mer-tech/Gravity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1mer-tech%2FGravity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1mer-tech%2FGravity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1mer-tech%2FGravity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1mer-tech%2FGravity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pr1mer-tech","download_url":"https://codeload.github.com/pr1mer-tech/Gravity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr1mer-tech%2FGravity/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267988352,"owners_count":24176993,"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-31T02:00:08.723Z","response_time":66,"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":["hacktoberfest","network","swift","swiftui"],"created_at":"2024-12-05T01:25:33.568Z","updated_at":"2025-07-31T04:33:13.839Z","avatar_url":"https://github.com/pr1mer-tech.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://gravity.pr1mer.tech/logo.svg\" width={150} height={150} /\u003e \n    \u003ch1 align=\"center\"\u003eGravity\u003c/h1\u003e\n\u003c/p\u003e\n\n\n## Introduction\n\nGravity is a SwiftUI library for remote data fetching. It uses **SWR** technonology to fetch data from the server.\n\nThe name “**SWR**” is derived from `stale-while-revalidate`, a cache invalidation strategy popularized by [HTTP RFC 5861](https://tools.ietf.org/html/rfc5861).\nGravity first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again.\n\nWith Gravity, components will get **a stream of data updates constantly and automatically**. Thus, the UI will be always **fast** and **reactive**.\n\n\u003cbr/\u003e\n\n## Quick Start\n\n#### Installation\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.\n\nIt is the recommended way to install Gravity.\n\nOnce you have your Swift package set up, adding Gravity as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/pr1mer-tech/Gravity.git\", .upToNextMajor(from: \"0.1.0\"))\n]\n```\nYou can then import and use Gravity:\n```swift\nimport SwiftUI\nimport Gravity\n\nstruct LandmarkList: View {\n    @SWR\u003cURL, Landmark\u003e(url: \"https://example.org/api/endpoint\") var api\n    var body: some View {\n        if let landmarks = api.data {\n            List(landmarks, id: \\.id) { landmark in\n                LandmarkRow(landmark: landmark)\n            }\n        }\n    }\n}\n```\n\nIn this example, the property wrapper `@SWR` accepts a `url` and a `model`.\n\nThe `url` is the URL of the API. And the `model` is a `Codable` object.\n\n`api` will be a `StateResponse` object that has three children: `data` that will contain the decoded data, `error` in case there is an error and `awaiting` when the app is loading.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr1mer-tech%2Fgravity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpr1mer-tech%2Fgravity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr1mer-tech%2Fgravity/lists"}