Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xleif/applicationkit
🧰 Application Lifecycle and AppState Enhancements
https://github.com/0xleif/applicationkit
apple application dependency-injection ios macos observable property-wrapper published state state-management swift swiftui tvos watchos
Last synced: 15 days ago
JSON representation
🧰 Application Lifecycle and AppState Enhancements
- Host: GitHub
- URL: https://github.com/0xleif/applicationkit
- Owner: 0xLeif
- License: mit
- Created: 2023-12-19T01:27:31.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2023-12-21T02:02:17.000Z (11 months ago)
- Last Synced: 2024-05-02T06:02:18.100Z (7 months ago)
- Topics: apple, application, dependency-injection, ios, macos, observable, property-wrapper, published, state, state-management, swift, swiftui, tvos, watchos
- Language: Swift
- Homepage: https://0xleif.github.io/ApplicationKit/
- Size: 18.6 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ApplicationKit
ApplicationKit is a Swift-based library that provides a rich set of tools for managing and working with application state. Building upon [AppState](https://github.com/0xLeif/AppState), it provides an additional layer of functionality to manage lifecycle notifications and state changes in applications.
## Features
- A streamlined approach to handling and observing different lifecycle notifications.
- A simplified interface to run closures only once from anywhere within the codebase.
- More to come...## Getting Started
### Requirements
- Swift 5.7 or later
- iOS 15.0 or later
- watchOS 8.0 or later
- macOS 11.0 or later
- tvOS 15.0 or later### Installation
You can integrate ApplicationKit into your project using Swift Package Manager.
Once you have your Swift package set up, adding ApplicationKit as a dependency is as easy as adding it to the dependencies value of your Package.swift file.
```swift
dependencies: [
.package(url: "https://github.com/0xLeif/ApplicationKit.git", from: "0.1.0")
]
```## Usage
To handle various application states, override the necessary methods in your custom application class:
```swift
private class MyApplication: LifecyleApplication {
override var lifecycleNotifications: [LifecyleNotification] {
super.lifecycleNotifications + [
// Your additional lifecycle notifications
]
}/// Gets called when application state becomes active
override func didBecomeActiveNotification(notification: Notification) {
// Custom code implementation
}
}
```In your App initialization, promote your custom application class:
```swift
Application.promote(to: MyApplication.self)
```Use ApplicationKit's `.runOnce` feature to run a specific closure code once within the lifecycle of the application:
```swift
Application.runOnce { performExpensiveTaskHere() }
```## Contributing
Pull requests are very welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
ApplicationKit is distributed under the MIT license. For more information, refer to the LICENSE file.