-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShowcaseState.scala
More file actions
27 lines (20 loc) · 871 Bytes
/
ShowcaseState.scala
File metadata and controls
27 lines (20 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package showcase.app
import scommons.react.redux.task.{AbstractTask, TaskAction}
import showcase.app.config.{ShowcaseConfig, ShowcaseConfigReducer}
trait ShowcaseStateDef {
def currentTask: Option[AbstractTask]
def config: ShowcaseConfig
}
case class ShowcaseState(currentTask: Option[AbstractTask],
config: ShowcaseConfig) extends ShowcaseStateDef
object ShowcaseStateReducer {
def reduce(state: Option[ShowcaseState], action: Any): ShowcaseState = ShowcaseState(
currentTask = currentTaskReducer(state.flatMap(_.currentTask), action),
config = ShowcaseConfigReducer(state.map(_.config), action)
)
private def currentTaskReducer(currentTask: Option[AbstractTask],
action: Any): Option[AbstractTask] = action match {
case a: TaskAction => Some(a.task)
case _ => currentTask
}
}