Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Arch Lifecycle management of Koin Context. #32

Closed
wants to merge 1 commit into from

Conversation

TonicArtos
Copy link

A lifecycle observer that can release the Koin Context and a couple of extension functions to make it easier to use.


I thought I'd just quickly crib this together from one of my projects and push it out here, in case it is useful for you or anybody following the project. The idea is to use the new Android Lifecycle Components to release the Koin context, retaining the flexibility of the existing approach. The only trouble is that it adds further dependencies to the project plus the use of the annotations processor.

Usage

class MainActivity : FragmentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)


        manageContext("MainActivityContext")


    }
}

manageContext can be called with an optional parameter to set which lifecycle event releases the context.

Please feel free to let me know what you think.

@arnaudgiuliani
Copy link
Member

Hello,

the koin-android module address only main Android features. I try to keep it as simple as possible. I'm thinking about a dedicated module for Android architecture components.

@TonicArtos
Copy link
Author

Okay, that sounds reasonable. Thanks for letting me know.

@arnaudgiuliani
Copy link
Member

Yeah, I keep it opened. I will tell you how it can be included in one of the next releases.

@arnaudgiuliani
Copy link
Member

Hello,

you can check the last release (0.8.0), about bringing a ViewModel factory to Android architecture API

@TonicArtos
Copy link
Author

TonicArtos commented Jan 8, 2018 via email

@arnaudgiuliani
Copy link
Member

Hello I propose to read incoming changes from koin-android-architecture module branch master. Feel free to give any suggestions. I close this PR then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants