Remove NodeBuilder to ensure that Params and Callback are always provided.
This commit is contained in:
parent
be03c50aaf
commit
02dc71c4c3
115 changed files with 954 additions and 1174 deletions
|
|
@ -17,13 +17,7 @@ interface ViewFolderEntryPoint : FeatureEntryPoint {
|
|||
val rootPath: String,
|
||||
)
|
||||
|
||||
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder
|
||||
|
||||
interface NodeBuilder {
|
||||
fun params(params: Params): NodeBuilder
|
||||
fun callback(callback: Callback): NodeBuilder
|
||||
fun build(): Node
|
||||
}
|
||||
fun createNode(parentNode: Node, buildContext: BuildContext, params: Params, callback: Callback): Node
|
||||
|
||||
interface Callback : Plugin {
|
||||
fun onDone()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ package io.element.android.features.viewfolder.impl
|
|||
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import com.bumble.appyx.core.plugin.Plugin
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import io.element.android.features.viewfolder.api.ViewFolderEntryPoint
|
||||
|
|
@ -18,23 +17,13 @@ import io.element.android.libraries.architecture.createNode
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultViewFolderEntryPoint : ViewFolderEntryPoint {
|
||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): ViewFolderEntryPoint.NodeBuilder {
|
||||
val plugins = ArrayList<Plugin>()
|
||||
|
||||
return object : ViewFolderEntryPoint.NodeBuilder {
|
||||
override fun params(params: ViewFolderEntryPoint.Params): ViewFolderEntryPoint.NodeBuilder {
|
||||
plugins += ViewFolderFlowNode.Inputs(params.rootPath)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun callback(callback: ViewFolderEntryPoint.Callback): ViewFolderEntryPoint.NodeBuilder {
|
||||
plugins += callback
|
||||
return this
|
||||
}
|
||||
|
||||
override fun build(): Node {
|
||||
return parentNode.createNode<ViewFolderFlowNode>(buildContext, plugins)
|
||||
}
|
||||
}
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext, params: ViewFolderEntryPoint.Params, callback: ViewFolderEntryPoint.Callback): Node {
|
||||
return parentNode.createNode<ViewFolderFlowNode>(
|
||||
buildContext = buildContext,
|
||||
plugins = listOf(
|
||||
ViewFolderFlowNode.Inputs(params.rootPath),
|
||||
callback,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,12 @@ class DefaultViewFolderEntryPointTest {
|
|||
val params = ViewFolderEntryPoint.Params(
|
||||
rootPath = "path",
|
||||
)
|
||||
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||
.params(params)
|
||||
.callback(callback)
|
||||
.build()
|
||||
val result = entryPoint.createNode(
|
||||
parentNode = parentNode,
|
||||
buildContext = BuildContext.root(null),
|
||||
params = params,
|
||||
callback = callback,
|
||||
)
|
||||
assertThat(result).isInstanceOf(ViewFolderFlowNode::class.java)
|
||||
assertThat(result.plugins).contains(ViewFolderFlowNode.Inputs(params.rootPath))
|
||||
assertThat(result.plugins).contains(callback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue