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.
 
 

19 lines
594 B

package com.example.playscalajsreact.model
import japgolly.scalajs.react.feature.Context
import japgolly.scalajs.react.React
import com.softwaremill.quicklens._
import monocle.macros.Lenses
import japgolly.scalajs.react.Reusability
@Lenses
case class MyGlobalState(user: Option[User] = None, name: String = "")
object MyGlobalState {
val ctx: Context[MyGlobalState] = React.createContext(MyGlobalState())
val modifyUsername = modify[MyGlobalState](_.user.each.username)
implicit val reusability: Reusability[MyGlobalState] = Reusability.derive
def empty = MyGlobalState(None, "")
}