Skip to content

Instantly share code, notes, and snippets.

@ericntd
Last active December 1, 2020 19:35
Show Gist options
  • Save ericntd/ad85fe1e25eb62d4a8b9eec4ee76abf9 to your computer and use it in GitHub Desktop.
Save ericntd/ad85fe1e25eb62d4a8b9eec4ee76abf9 to your computer and use it in GitHub Desktop.
Action Card 2.0

ActionCardInteractorV2 (More about Dagger multi-binding here)

@Inject
lateinit var cardHandlers : Map<String, com.coffeemeetsbagel.components.Builder>
//...

override fun didBecomeActive() {
    super.didBecomeActive()
    val key = theActionCard.action
    val ribBuilder : Builder? = cardHandlers[key]
    if (ribBuilder == null) {
        ribBuilder = DefaultActionCardBuilder(component)
    }
    val childRouter = ribBuilder.createRouter(view)
    router.attach(childRouter)
    view.add(childRouter.view)
}

DefaultActionCardInteractor (very similar to ActionCard 1.0)

override fun onActionButtonClicked() {
    router.routeTo(theActionCard.destination) // example of destination "cmb://discover"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment