Git Product home page Git Product logo

sealant's Introduction

[WIP] Sealant

GitHub release License

Sealant creates Dagger bindings and integrations for Android classes using the Anvil. This is meant to be an alternative to Hilt, for those who'd prefer to enjoy the faster compilation and better flexibility of Anvil.

Since Sealant is an extension upon Anvil, its code generation will be applied to Kotlin files only.

Inspired by: Marcello Galhardo article N26 Path to Anvil, Zac Sweers article Extending Anvil for Fun and Profit and Rick Busarow library Tangle

Setup

Add dependencies:

dependencies {
    def sealant_version = "0.2.1"

    // Common
    implementation "io.github.steinerok.sealant:di-common:${sealant_version}"
    // Core
    implementation "io.github.steinerok.sealant:sealant-core-api:${sealant_version}"
    anvil "io.github.steinerok.sealant:sealant-core-codegen:${sealant_version}"
    // Appcomponent
    implementation "io.github.steinerok.sealant:sealant-appcomponent-api:${sealant_version}"
    anvil "io.github.steinerok.sealant:sealant-appcomponent-codegen:${sealant_version}"
    // Fragment
    implementation "io.github.steinerok.sealant:sealant-fragment-api:${sealant_version}"
    anvil "io.github.steinerok.sealant:sealant-fragment-codegen:${sealant_version}"
    // ViewModel
    implementation "io.github.steinerok.sealant:sealant-viewmodel-api:${sealant_version}"
    anvil "io.github.steinerok.sealant:sealant-viewmodel-codegen:${sealant_version}"
    // WorkManager
    implementation "io.github.steinerok.sealant:sealant-work-api:${sealant_version}"
    anvil "io.github.steinerok.sealant:sealant-work-codegen:${sealant_version}"
}

Make sure that you have mavenCentral() in the list of repositories:

repositories {
    mavenCentral()
}

Features

Core

@SealantConfiguration(
    addAppcomponentSupport = true,
    addViewModelSupport = true,
    addFragmentSupport = true,
    addWorkSupport = true,
)
abstract class AppScope private constructor()

Appcomponent

@InjectWith(AppScope::class)
class MainActivity : ComponentActivity() {
    /* Your dependencies, inject via lateinit var and @Inject annotation */
}

Fragment

@ContributesFragment(scope = AppScope::class)
class MainFragment @Inject constructor(
    /* Your dependencies */
)

ViewModel

@ContributesViewModel(AppScope::class)
class MainViewModel @Inject constructor(
    private val application: Application,
    private val ssHandle: SavedStateHandle,
    /* Your dependencies */
) : ViewModel()

Work

@ContributesWorker(AppScope::class)
class MainWorker2 @AssistedInject constructor(
    @Assisted appContext: Context,
    @Assisted params: WorkerParameters,
    /* Your dependencies */
) : CoroutineWorker(appContext, params) {
    override suspend fun doWork(): Result = TODO()
}

Contributions

Please contribute! I will gladly review any pull requests. Make sure to read the Contributing page first though.

License

Copyright (c) 2022-2023 Ihor Kushnirenko

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

sealant's People

Contributors

steinerok avatar renovate[bot] avatar

Watchers

James Cloos avatar  avatar

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.