Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edonv/asyncbutton
Wrapper view of Button that supports asynchronous code.
https://github.com/edonv/asyncbutton
async-await button concurrency ios swift swiftui
Last synced: about 1 month ago
JSON representation
Wrapper view of Button that supports asynchronous code.
- Host: GitHub
- URL: https://github.com/edonv/asyncbutton
- Owner: edonv
- License: mit
- Created: 2023-12-26T20:48:57.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-05-09T19:28:54.000Z (6 months ago)
- Last Synced: 2024-10-12T18:02:39.550Z (about 1 month ago)
- Topics: async-await, button, concurrency, ios, swift, swiftui
- Language: Swift
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AsyncButton
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fedonv%2FAsyncButton%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/edonv/AsyncButton)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fedonv%2FAsyncButton%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/edonv/AsyncButton)This is a convenience type for encapsulating asynchronous logic in a SwiftUI `Button`. The initial base of this code was taken from John Sundell's article here: . This included the main idea and structure of `AsyncButton`. I restuctured it in various ways (i.e. using `OptionSet` for `ActionOptions`, backporting to iOS 13, using the `.task` modifier instead of a nested `Task`, the extra convenience initializers, etc.).
## To-Do's
- [ ] Create environment values (internal ones that are used by public modifiers) for more granular settings
- [ ] Animation for changes to `isEnabled` and `isShowingPlaceholder`
- [ ] Duration to wait before showing the placeholder view (`minAsyncDuration`), which is used just in case `action` is so fast, nothing is needed to be shown
- [ ] ActionOptions