Created
May 16, 2014 18:03
-
-
Save ripla/9ee0c86af02f18564665 to your computer and use it in GitHub Desktop.
Quick draft of View-Presenter injection with the cake pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait SomeView { | |
def render(): Unit | |
def init(): Unit | |
} | |
trait SomeViewComponent { | |
this: SomePresenterComponent => | |
val someView: SomeView | |
class SomeViewImpl extends SomeView { | |
presenter.view = this | |
def render() = Console.println("Rendering!") | |
def init() = presenter.init() | |
} | |
} | |
trait SomePresenterComponent { | |
val presenter: SomePresenter | |
class SomePresenter { | |
var view: SomeView = _ | |
def init() = view.render() | |
} | |
} | |
class ComponentRegistry extends SomePresenterComponent with SomeViewComponent { | |
val presenter = new SomePresenter() | |
val someView = new SomeViewImpl() | |
} | |
val view = new ComponentRegistry().someView | |
view.init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment