Skip to content

Commit

Permalink
Updated PresenterFactory documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
chRyNaN committed Mar 25, 2022
1 parent 99db779 commit 7a6b13d
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,48 @@ internal class PresenterFactoryDelegate<I : Intent, S : State, C : Change>(
}
}

/**
* Creates a [PresenterFactory] delegate.
*
* Example usage:
*
* ```kotlin
* val presenter by presenterFactory { intents ->
* Presenter(intents) {
* this.view.intents()
* .perform { intent, state -> ... }
* .reduce { state, change -> ... }
* .startWithInitialState()
* .render()
* .launchIn(coroutineScope)
* }
* }
* ```
*/
fun <I : Intent, S : State, C : Change> presenterFactory(
retainInstance: Boolean = true,
factory: PresenterFactory<I, S, C>
): ReadOnlyProperty<View<I, S>, Presenter<I, S, C>> =
PresenterFactoryDelegate(factory = factory, retainInstance = retainInstance)

/**
* Creates a [PresenterFactory] delegate.
*
* Example usage:
*
* ```kotlin
* val presenter by presenterFactory { intents ->
* Presenter(intents) {
* this.view.intents()
* .perform { intent, state -> ... }
* .reduce { state, change -> ... }
* .startWithInitialState()
* .render()
* .launchIn(coroutineScope)
* }
* }
* ```
*/
fun <I : Intent, S : State, C : Change> presenterFactory(
retainInstance: Boolean = true,
factory: (intents: Flow<I>) -> Presenter<I, S, C>
Expand Down

0 comments on commit 7a6b13d

Please sign in to comment.