You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
package outwatchapp
|
|
|
|
import com.softwaremill.macwire._
|
|
import monix.bio.Task
|
|
import org.scalajs.dom.raw.Element
|
|
import outwatch._
|
|
import outwatch.dsl._
|
|
import outwatch.router._
|
|
import outwatchapp.components.CounterDemo
|
|
import outwatchapp.components.RequestDemo
|
|
import outwatchapp.components.todo.ChartjsDemo
|
|
import outwatchapp.pages.HomePage
|
|
import nova.monadic_sfx.ui.components.todo.TodoListStore
|
|
|
|
class MainApp(el: Element)(implicit
|
|
backend: AppTypes.Backend,
|
|
store: RouterStore[Page]
|
|
) {
|
|
def run: Task[Unit] = for {
|
|
resolver <- resolver
|
|
_ <- OutWatch.renderInto[Task](el, Router(resolver))
|
|
} yield ()
|
|
|
|
def resolver: Task[PartialFunction[Page, VDomModifier]] =
|
|
Task.deferAction(implicit s =>
|
|
for {
|
|
counterDemo <- CounterDemo()
|
|
chartDemo <- ChartjsDemo()
|
|
todoStore <- TodoListStore()
|
|
requestDemo <- RequestDemo(todoStore)
|
|
resolver: PartialFunction[Page, VDomModifier] = {
|
|
case Page.Home => wire[HomePage].render
|
|
case Page.SomePage =>
|
|
div(
|
|
div(cls := "title", "SomePage"),
|
|
// RequestDemo(todoStore),
|
|
requestDemo,
|
|
div(cls := "slider")
|
|
)
|
|
case Page.UserHome(id) =>
|
|
div(div(cls := "title", "UserHome"), s"User id: $id")
|
|
case Page.NotFound =>
|
|
div(
|
|
div(cls := "title", "NotFound"),
|
|
p(cls := "profile-description", "notfound")
|
|
)
|
|
}
|
|
} yield resolver
|
|
)
|
|
}
|