• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala ReactConnector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中diode.react.ReactConnector的典型用法代码示例。如果您正苦于以下问题:Scala ReactConnector类的具体用法?Scala ReactConnector怎么用?Scala ReactConnector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ReactConnector类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: AppCircuit

//设置package包名称以及导入依赖的类
package scalafiddle.client

import diode.ActionResult.{ModelUpdate, ModelUpdateSilent}
import diode._
import diode.data.{Empty, Ready}
import diode.react.ReactConnector
import upickle.default._

import scala.scalajs.js
import scala.scalajs.js.JSON
import scalafiddle.client.AppRouter.Home
import scalafiddle.shared._

object AppCircuit extends Circuit[AppModel] with ReactConnector[AppModel] {
  // load from global config
  def fiddleData = read[FiddleData](JSON.stringify(js.Dynamic.global.ScalaFiddleData))

  override protected def initialModel =
    AppModel(Home,
             None,
             fiddleData,
             ScalaFiddleHelp(ScalaFiddleConfig.helpURL),
             LoginData(Empty, Empty))

  override protected def actionHandler = composeHandlers(
    new FiddleHandler(zoomRW(_.fiddleData)((m, v) => m.copy(fiddleData = v)),
                      zoomRW(_.fiddleId)((m, v) => m.copy(fiddleId = v))),
    new CompilerHandler(zoomRW(_.outputData)((m, v) => m.copy(outputData = v))),
    new LoginHandler(zoomRW(_.loginData)((m, v) => m.copy(loginData = v))),
    navigationHandler
  )

  override def handleFatal(action: Any, e: Throwable): Unit = {
    println(s"Error handling action: $action")
    println(e.toString)
  }

  override def handleError(e: String): Unit = {
    println(s"Error in circuit: $e")
  }

  val navigationHandler: (AppModel, Any) => Option[ActionResult[AppModel]] = (model, action) =>
    action match {
      case NavigateTo(page) =>
        Some(ModelUpdate(model.copy(navLocation = page)))
      case NavigateSilentTo(page) =>
        Some(ModelUpdateSilent(model.copy(navLocation = page)))
      case _ =>
        None
  }
} 
开发者ID:scalafiddle,项目名称:scalafiddle-editor,代码行数:52,代码来源:AppCircuit.scala


示例2: ConcreteAppCircuit

//设置package包名称以及导入依赖的类
package client

import client.handlers.{AjaxHandlersComponent, CounterHandlerComponent}
import client.model._
import diode._
import diode.react.ReactConnector
import org.scalajs.dom

trait AppCircuitComponent {
  val appCircuit: AppCircuit

  trait AppCircuit extends Circuit[RootModel] with ReactConnector[RootModel]
}

trait ConcreteAppCircuitWired extends AppCircuitComponent {
  this: CounterHandlerComponent with AjaxHandlersComponent with InitialModelComponent =>

  override lazy val appCircuit       = new ConcreteAppCircuit
  private lazy val initialModelProxy = initialModel

  class ConcreteAppCircuit extends AppCircuit {

    val logActions = false

    class LoggingProcessor[M <: AnyRef] extends ActionProcessor[M] {
      def process(dispatch: Dispatcher, action: Any, next: Any => ActionResult[M], currentModel: M): ActionResult[M] = {
        dom.console.log(s"dispatching ${action.toString.take(80)}")
        next(action)
      }
    }

    if (logActions) {
      addProcessor(new LoggingProcessor[RootModel])
    }

    override def handleError(msg: String): Unit = {
      dom.console.error(s"handle error called with message $msg")
      super.handleError(msg)
    }

    override def handleFatal(action: Any, e: Throwable): Unit = {
      dom.console.error(
        s"handle fatal called with ${action.toString.take(80)} $e"
      )
      super.handleFatal(action, e)
    }

    override def actionHandler: HandlerFunction =
      foldHandlers(
        composeHandlers(
          counterHandlers.actionHandler,
          ajaxHandlers.actionHandler
        ),
        ajaxHandlers.eventHandler
      )

    override def initialModel: RootModel = initialModelProxy
  }

} 
开发者ID:igeolise,项目名称:single-page-app-skeleton,代码行数:61,代码来源:AppCircuitComponent.scala


示例3: RootModel

//设置package包名称以及导入依赖的类
package com.omis.client.services

import com.omis.User
import com.omis.client.RootModels.{EmployeeRootModel, EmployeesRootModel, UserRootModel}
import com.omis.client.handlers.{EmployeeHandler, EmployeesHandler, UserHandler}
import diode.Circuit
import diode.data.{Empty, Pot}
import diode.react.ReactConnector

case class RootModel(user: UserRootModel, emps: Pot[EmployeesRootModel], emp: Pot[EmployeeRootModel])

object OmisCircuit extends Circuit[RootModel] with ReactConnector[RootModel] {
  // initial application model
  override protected def initialModel = RootModel(
    UserRootModel(User(java.util.UUID.randomUUID(), "", "")), Pot.empty, Pot.empty
  )

  // combine all handlers into one
  override protected val actionHandler = composeHandlers(
    new UserHandler(zoomRW(_.user)((m, v) => m.copy(user = v))),
    new EmployeesHandler(zoomRW(_.emps)((m, v) => m.copy(emps = v))),
    new EmployeeHandler(zoomRW(_.emp)((m, v) => m.copy(emp = v)))
  )
} 
开发者ID:iriddhi,项目名称:mis,代码行数:25,代码来源:OmisCircuit.scala


示例4: SaavCircuit

//设置package包名称以及导入依赖的类
package ch.fhnw.ima.saav.circuit

import ch.fhnw.ima.saav.model.app._
import diode._
import diode.react.ReactConnector

class SaavCircuit extends Circuit[SaavModel] with ReactConnector[SaavModel] {

  override protected def initialModel = SaavModel()

  private val analysisImportHandler =
    new AnalysisImportHandler(zoomRW(AnalysisImportHandler.modelGet)(AnalysisImportHandler.modelSet))

  private val colorHandler =
    new ColorHandler(zoomRW(ColorHandler.modelGet)(ColorHandler.modelSet))

  private val entitySelectionHandler =
    new EntitySelectionHandler(zoomRW(EntitySelectionHandler.modelGet)(EntitySelectionHandler.modelSet))

  private val subCriteriaSelectionHandler =
    new SubCriteriaSelectionHandler(zoomRW(SubCriteriaSelectionHandler.modelGet)(SubCriteriaSelectionHandler.modelSet))

  private val expertConfigHandler =
    new ExpertConfigHandler(zoomRW(ExpertConfigHandler.modelGet)(ExpertConfigHandler.modelSet))

  private val chartLayoutHandler =
    new ChartLayoutHandler(zoomRW(ChartLayoutHandler.modelGet)(ChartLayoutHandler.modelSet))

  private val pdfExportHandler =
    new PdfExportHandler(zoomRW(PdfExportHandler.modelGet)(PdfExportHandler.modelSet))

  override protected val actionHandler: HandlerFunction =
    composeHandlers(
      analysisImportHandler,
      colorHandler,
      entitySelectionHandler,
      subCriteriaSelectionHandler,
      expertConfigHandler,
      chartLayoutHandler,
      pdfExportHandler
    )

  override def handleError(msg: String): Unit = {
    val name = getClass.getSimpleName
    println(s"[$name] Error: $msg")
  }

} 
开发者ID:fhnw-saav,项目名称:saav,代码行数:49,代码来源:SaavCircuit.scala


示例5: AppCircuit

//设置package包名称以及导入依赖的类
package weatherApp.diode

import diode._
import diode.react.ReactConnector
import weatherApp.models.{GithubUser, WeatherForecastResponse, WeatherResponse}

object AppCircuit extends Circuit[AppModel] with ReactConnector[AppModel] {
  def initialModel = AppModel(
    AppState(
      weatherSuggestions = List.empty[WeatherResponse],
      forecast = None: Option[WeatherForecastResponse],
      selectedWeather = None: Option[WeatherResponse],
      isLoading = false,
      user = None : Option[GithubUser]
    )
  )

  override val actionHandler = composeHandlers(
    new WeatherPageHandler(zoomTo(_.state)),
    new AppHandler(zoomTo(_.state))
  )
}

class WeatherPageHandler[M](modelRW: ModelRW[M, AppState]) extends ActionHandler(modelRW) {
  override def handle = {
    case GetWeatherSuggestions(weatherSuggestions) => updated(value.copy(weatherSuggestions = weatherSuggestions))
    case GetWeatherForecast(forecast) => updated(value.copy(forecast = forecast))
    case ClearForecast() => updated(value.copy(forecast = None))
    case SelectWeather(weather) => updated(value.copy(selectedWeather = weather))
  }
}

class AppHandler[M](modelRW: ModelRW[M, AppState]) extends ActionHandler(modelRW) {
  override def handle = {
    case SetLoadingState() => updated(value.copy(isLoading = true))
    case ClearLoadingState() => updated(value.copy(isLoading = false))
    case GetUserInfo(user) => updated(value.copy(user = user))
  }
} 
开发者ID:malaman,项目名称:scala-weather-app,代码行数:40,代码来源:AppCircuit.scala


示例6: AppCircuit

//设置package包名称以及导入依赖的类
package net.devkat.pegasus

import diode._
import diode.react.ReactConnector
import net.devkat.pegasus.actions._
import net.devkat.pegasus.model._


object AppCircuit extends Circuit[RootModel] with ReactConnector[RootModel] {
  def initialModel = RootModel(
    Flow(Vector(Section(children = Vector(Paragraph(children = Vector(Character(ch = 'a'))))))),
    None
  )

  override val actionHandler = composeHandlers(
    new FlowHandler(zoomRW(_.flow)((m, v) => m.copy(flow = v))),
    new SelectionHandler(zoomRW(_.selection)((m, v) => m.copy(selection = v)))
  )
} 
开发者ID:devkat,项目名称:pegasus,代码行数:20,代码来源:AppCircuit.scala


示例7: DashboardModel

//设置package包名称以及导入依赖的类
package kidstravel.client.services

import autowire._
import diode._
import diode.data._
import diode.react.ReactConnector
import kidstravel.shared.Api
import boopickle.Default._
import diode.ActionResult.{ModelUpdate, ModelUpdateEffect}
import kidstravel.shared.geo.{City, CityLabel}
import kidstravel.shared.poi.Poi

case class DashboardModel(
  cityCandidates: Pot[Seq[CityLabel]],
  topCities: Pot[Seq[(City, Pot[FlickrImage])]]
)

// The base model of our application
case class RootModel(
  dashboard: DashboardModel,
  city: Pot[City],
  pois: PotMap[Long, Poi]
)

// Application circuit
object KidsTravelCircuit extends Circuit[RootModel] with ReactConnector[RootModel] {

  // initial application model
  override protected def initialModel =
    RootModel(DashboardModel(Empty, Empty), Empty, PotMap(new PoiFetch(this)))

  // combine all handlers into one
  override protected val actionHandler = composeHandlers(
    new PoiHandler(zoomRW(_.pois)((m, v) => m.copy(pois = v))),
    new CitySearchHandler(
      zoomRW(_.dashboard)((m, v) => m.copy(dashboard = v)).
      zoomRW(_.cityCandidates)((m, v) => m.copy(cityCandidates = v))),
    new TopCitiesHandler(
      zoomRW(_.dashboard)((m, v) => m.copy(dashboard = v)).
      zoomRW(_.topCities)((m, v) => m.copy(topCities = v))),
    new CityHandler(zoomRW(_.city)((m, v) => m.copy(city = v)))
  )
} 
开发者ID:devkat,项目名称:kidstravel,代码行数:44,代码来源:KidsTravelCircuit.scala



注:本文中的diode.react.ReactConnector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala ScalatraServlet类代码示例发布时间:2022-05-23
下一篇:
Scala Bean类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap