CheeseWire

Lifecycle-friendly view binding in Kotlin for Conductor and others.

License

License

Categories

Categories

Wire Data Data Structures
GroupId

GroupId

de.hannesstruss.cheesewire
ArtifactId

ArtifactId

cheesewire
Last Version

Last Version

0.3.1
Release Date

Release Date

Type

Type

aar
Description

Description

CheeseWire
Lifecycle-friendly view binding in Kotlin for Conductor and others.
Project URL

Project URL

https://github.com/hannesstruss/cheesewire
Source Code Management

Source Code Management

https://github.com/hannesstruss/cheesewire

Download cheesewire

How to add to project

<!-- https://jarcasting.com/artifacts/de.hannesstruss.cheesewire/cheesewire/ -->
<dependency>
    <groupId>de.hannesstruss.cheesewire</groupId>
    <artifactId>cheesewire</artifactId>
    <version>0.3.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/de.hannesstruss.cheesewire/cheesewire/
implementation 'de.hannesstruss.cheesewire:cheesewire:0.3.1'
// https://jarcasting.com/artifacts/de.hannesstruss.cheesewire/cheesewire/
implementation ("de.hannesstruss.cheesewire:cheesewire:0.3.1")
'de.hannesstruss.cheesewire:cheesewire:aar:0.3.1'
<dependency org="de.hannesstruss.cheesewire" name="cheesewire" rev="0.3.1">
  <artifact name="cheesewire" type="aar" />
</dependency>
@Grapes(
@Grab(group='de.hannesstruss.cheesewire', module='cheesewire', version='0.3.1')
)
libraryDependencies += "de.hannesstruss.cheesewire" % "cheesewire" % "0.3.1"
[de.hannesstruss.cheesewire/cheesewire "0.3.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk7 jar 1.2.41
com.android.support » support-annotations jar 27.0.2

Project Modules

There are no modules declared in this project.

⚠️ Deprecated

CheeseWire is deprecated. From Android Gradle Plugin 3.6 on, you should use ViewBinding.

CheeseWire

Lifecycle-friendly view binding in Kotlin for Conductor.

Build Status Maven Central

To use, add a ConductorViewBinder to your base controller:

abstract class BaseController : Controller() {
  protected val views = ConductorViewBinder(this)
}

This can now be used to bind views in your concrete controllers:

class HomeController : BaseController() {
  private val btnLogin: Button by views.bind(R.id.btn_login)
}

during onDestroyView, the view binder is reset, and your views aren't leaked.

See the sample app for an example.

Generic lazy

CheeseWire view binders also provide a generic lazy property delegate which is synchronized with your view property lifecycle. This comes in handy e.g. in combination with RxBinding when you want to avoid calling the RxBinding methods twice on a view:

class MyMviController : BaseController() {
  private val btnLogin: Button by views.bind(R.id.btn_login)
  private val btnSignup: Button by views.bind(R.id.btn_login)

  val intentions by views.lazy {
    Observable.merge(
        btnLogin.clicks().map { Intention.Login },
        btnSignup.clicks().map { Intention.Signup }
    )
  }
}

Download

dependencies {
  implementation 'de.hannesstruss.cheesewire:cheesewire-conductor:0.2'
}

Attributions 🙇

CheeseWire is inspired by the awesome work of ButterKnife, KotterKnife and ButterknifeConductor.

License

Copyright (C) 2017 Hannes Struss

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.

Versions

Version
0.3.1
0.3
0.2