Skip to content

Instantly share code, notes, and snippets.

@Lamartio
Last active September 24, 2018 07:33
Show Gist options
  • Save Lamartio/b3dc52bfaf7e7c6aab3e563c8d82895c to your computer and use it in GitHub Desktop.
Save Lamartio/b3dc52bfaf7e7c6aab3e563c8d82895c to your computer and use it in GitHub Desktop.

Revisions

  1. Lamartio revised this gist Sep 24, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion BindableLayout.kt
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ open class BindableLayout<T, V : ViewGroup>(layout: V) : Layout<V>(layout) {
    private inner class Observers : ArrayList<Observer<T>>(), Consumer<T> {

    override fun accept(value: T) =
    forEach { subscription -> subscription(value, value) }
    forEach { observer -> observer(value, value) }

    }

  2. Lamartio revised this gist Sep 24, 2018. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions BindableLayout.kt
    Original file line number Diff line number Diff line change
    @@ -6,10 +6,11 @@ open class BindableLayout<T, V : ViewGroup>(layout: V) : Layout<V>(layout) {
    observers.add(observer)
    }

    private inner class Observers : MutableList<Observer<T>> by mutableListOf(), Consumer<T> {
    private inner class Observers : ArrayList<Observer<T>>(), Consumer<T> {

    override fun accept(value: T) = forEach { subscription -> subscription(value, value) }
    override fun accept(value: T) =
    forEach { subscription -> subscription(value, value) }

    }

    }
  3. Lamartio revised this gist Sep 24, 2018. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions BindableLayout.kt
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,4 @@ open class BindableLayout<T, V : ViewGroup>(layout: V) : Layout<V>(layout) {

    }

    /*
    ...
    */
    }
  4. Lamartio created this gist Sep 24, 2018.
    18 changes: 18 additions & 0 deletions BindableLayout.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    open class BindableLayout<T, V : ViewGroup>(layout: V) : Layout<V>(layout) {

    private val observers = Observers()

    fun bind(observer: Observer<T>) {
    observers.add(observer)
    }

    private inner class Observers : MutableList<Observer<T>> by mutableListOf(), Consumer<T> {

    override fun accept(value: T) = forEach { subscription -> subscription(value, value) }

    }

    /*
    ...
    */
    }