Giter Site home page Giter Site logo

0xleif / applicationkit Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 19 KB

🧰 Application Lifecycle and AppState Enhancements

Home Page: https://0xleif.github.io/ApplicationKit/

License: MIT License

Swift 100.00%
apple application ios macos observable property-wrapper state state-management swift swiftui

applicationkit's Introduction

ApplicationKit

ApplicationKit is a Swift-based library that provides a rich set of tools for managing and working with application state. Building upon 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.

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:

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:

Application.promote(to: MyApplication.self)

Use ApplicationKit's .runOnce feature to run a specific closure code once within the lifecycle of the application:

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.

applicationkit's People

Contributors

0xleif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

applicationkit's Issues

DocC Error

 /Users/runner/work/ApplicationKit/ApplicationKit/Sources/ApplicationKit/LocationApplication/LocationApplication.swift:28:15: error: cannot override 'locationManager' which has been marked unavailable: Implement -locationManager:didUpdateLocations: instead
    open func locationManager(_ manager: CLLocationManager, didUpdateTo newLocation: CLLocation, from oldLocation: CLLocation) { }

https://github.com/0xLeif/ApplicationKit/actions/runs/7270083770/job/19808642563

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.