Skip to content

Conversation

@eboudrant
Copy link
Contributor

Example to illustrate problem with `@DslMarker1 and this pattern :

class Controller(val object : ...) ... {
  fun buildModels(...) {
   group {
      addSomething(...)
    }
  }
  open fun ModelCollector.addSomething(...) {
    model {
      onClick { object.doSomething(...) }
    }
  }
}


this@MainController.addColoredSquareView(Color.DKGRAY)
this@MainController.addColoredSquareView(Color.GRAY)
this@MainController.addColoredSquareView(Color.LTGRAY)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is here :

e: kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainController.kt: (66, 33): 'fun ModelCollector.addColoredSquareView(color: Int): Unit' can't be called in this context by implicit receiver. Use the explicit one if necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will work with

        decoratedLinearGroup {
            val group = this
            id("epoxyModelGroupWithLayoutDsl")
            with (this@MainController) {
                group.addColoredSquareView(Color.DKGRAY)
                group.addColoredSquareView(Color.GRAY)
                group.addColoredSquareView(Color.LTGRAY)
            }
        }

but this is not ideal.

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.

1 participant