{"id":17976792,"url":"https://github.com/unixzii/swiftui-hooks","last_synced_at":"2025-03-25T15:31:22.249Z","repository":{"id":68261615,"uuid":"191503333","full_name":"unixzii/SwiftUI-Hooks","owner":"unixzii","description":"A PoC for implementing hooks in SwiftUI","archived":false,"fork":false,"pushed_at":"2019-06-12T13:55:16.000Z","size":23,"stargazers_count":82,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T13:13:31.136Z","etag":null,"topics":["apple","hooks","ios","react","swift","swiftui"],"latest_commit_sha":null,"homepage":null,"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/unixzii.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":"2019-06-12T05:28:09.000Z","updated_at":"2024-08-15T08:17:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8e6c6ed-dabc-4b0f-936e-8fc46eee5015","html_url":"https://github.com/unixzii/SwiftUI-Hooks","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/unixzii%2FSwiftUI-Hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unixzii%2FSwiftUI-Hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unixzii%2FSwiftUI-Hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unixzii%2FSwiftUI-Hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unixzii","download_url":"https://codeload.github.com/unixzii/SwiftUI-Hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245489764,"owners_count":20623789,"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":["apple","hooks","ios","react","swift","swiftui"],"created_at":"2024-10-29T17:25:07.548Z","updated_at":"2025-03-25T15:31:22.244Z","avatar_url":"https://github.com/unixzii.png","language":"Swift","readme":"#  SwiftUI Hooks\n\n\u003e Note: This is only a proof of concept, not for production use yet.\n\n## Quick Start\n\n```swift\nlet ContentView = { RendererView { hooks in\n    let (counter, setCounter) = hooks.useState(initial: 0)\n    hooks.useEffect {\n        if counter == 5 {\n            alert(\"High five!\")\n        }\n    }\n    hooks.useEffect({\n        alert(\"Hi there!\")\n    }, dep: RendererView.triggerOnce)\n\n    return VStack {\n        Text(\"Current value: \\(counter)\")\n        HStack {\n            Button(action: { setCounter(counter + 1) }) { Text(\"+\") }\n            Button(action: { setCounter(counter - 1) }) { Text(\"-\") }\n        }\n    }\n    .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)\u003e*\n} }\n```\n\n## Prior Art\n\nThis is fully inspired by [React Hooks](https://reactjs.org/docs/hooks-intro.html). To learn more about what hooks are doing, please first check out the React documentation. And the API design in this PoC also follows the React spec, you can literally map what you learned to this.\n\n## Examples\n\n* [Todo List](https://github.com/unixzii/SwiftUI-Hooks/blob/master/SwiftUI-Hooks/ContentView.swift#L59)\n\n## API References\n\n*TBD.*\n\nSee [RendererView.swift](https://github.com/unixzii/SwiftUI-Hooks/blob/master/SwiftUI-Hooks/RendererView.swift#L12).\n\n## Todos\n\n- [ ] `useEffect` with cleanup.\n- [ ] Detection of inconsistent hook calls.\n- [ ] ...\n\n## Contribution\n\nThis repository won't accept PRs about detail design. If you are interested in making it a library, feel free to leave an issue and let me know.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funixzii%2Fswiftui-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funixzii%2Fswiftui-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funixzii%2Fswiftui-hooks/lists"}