This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getSystemStatusInfo(id: String): Option[SystemStatusInfo] = ??? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class SystemStatusInfo(system: System, status: SystemStatus) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val systemStatusMap: Map[String, SystemStatus] = Map( | |
| "consumer_desktop" -> Red, | |
| "consumer_msite" -> Green | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getOwnerName(systemId: String): Option[String] = { | |
| systemsMap.get(systemId).flatMap(system => ownersMap.get(system.ownerId)).map(_.name) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> getOwnerName("consumer_desktop") | |
| res0: Option[String] = Some(Consumer web team) | |
| scala> getOwnerName("no_such_system_id") | |
| res3: Option[String] = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getOwnerName(systemId: String): Option[String] = { | |
| val systemOption: Option[System] = systemsMap.get(systemId) | |
| val ownerOption: Option[Owner] = systemOption.flatMap(system => ownersMap.get(system.ownerId)) | |
| ownerOption.map(owner => owner.name) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> systemsMap.get("consumer_desktop") | |
| res1: Option[System] = Some(System(consumer_desktop,realestate.com.au desktop site,consumer_web)) | |
| scala> systemsMap.get("unknown") | |
| res2: Option[System] = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val systemsMap = Map( | |
| "consumer_desktop" -> System(id = "consumer_desktop", name = "realestate.com.au desktop site", ownerId = "consumer_web"), | |
| "consumer_msite" -> System(id = "consumer_msite", name = "realestate.com.au mobile site", ownerId = "consumer_web") | |
| ) | |
| val ownersMap = Map( | |
| "consumer_web" -> Owner(id = "consumer_web", name = "Consumer web team"), | |
| "consumer_apps" -> Owner(id = "consumer_apps", name = "Consumer apps team") | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class System(id: String, name: String, ownerId: String) | |
| case class Owner(id: String, name: String) | |
| sealed trait SystemStatus | |
| case object Green extends SystemStatus | |
| case object Red extends SystemStatus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const stateUpdaterProvider = stateTransformers => Component => { | |
| class StateUpdaterProvider extends React.Component { | |
| getChildContext() { | |
| return stateTransformers; | |
| } | |
| render() { | |
| return <Component {...this.props} />; | |
| } | |
| } |