Skip to content

Instantly share code, notes, and snippets.

View chandu0101's full-sized avatar

Chandra Sekhar Kode chandu0101

  • Vijayawada,India
View GitHub Profile
// This file allows us to inspect the traffic going over the Native <-> JS bridge, and can be
// helpful for debugging. Setting this to true should never be committed to git
const ENABLE_BRIDGE_DEBUGGER = false; // <-- THIS SHOULD NOT BE TRUE IN MASTER!!!!
// if true, function arguments will get pretty printed
const PRETTY_PRINT = false;
// enable this if you want to ignore EVERY event, except for the ones that match the `FOCUSED_*`
// constants. If true, you configure what you want to see. If false, you configure what you DONT
// want to see.
package sri.web.vdom
import sri.core._
import sri.universal.components._
import sri.web.SyntheticEvent
import sri.web.all._
import scala.scalajs.js
import scala.scalajs.js.annotation.ScalaJSDefined
import scala.scalajs.js.{UndefOr => U, undefined => undefined}
def toProps(in : Attr[_,_]*) = {
val p = js.Dictionary.empty[Any]
in.foreach(t => if(t != null) p.update(t.key, t.value))
p
}
def div(attrs: Attr[DivAttr,_]*)(children: ReactNode*) = React.createElement("div", toProps(attrs :_*), children : _*)
def input(attrs: Attr[InputAttr,_]*)(children: ReactNode*) = React.createElement("input", toProps(attrs :_*), children : _*)
import org.scalajs.dom
object ScalaJSExample extends js.JSApp{
case class FieldName(name : String , tpe : String)
def main(): Unit = {
val name = "SeedCategory"
[
{
"name": "User",
"kind": "OBJECT",
"interfaces": [
"Node"
],
"fields": [
{
"name": "id",
val customFullOpt = Def.taskKey[File]("Generate the file ..")
artifactPath in Compile in customFullOpt :=
baseDirectory.value / "final-bundle.js",
customFullOpt in Compile := {
val outFile = (artifactPath in Compile in customFullOpt).value
val loaderFile = (resourceDirectory in Compile).value / "loader.js" // file to prepended
IO.copyFile(loaderFile, outFile)
val fullOutputCode = IO.read((fullOptJS in Compile).value.data)
@ScalaJSDefined
class Hello extends React.Component {
def render() = {
Reac.createElement("div")
}
}
// render
React.render(React.createFactory(new Hello()), dom.document.body)
//snippets of rx and scalajs-react for my research ..
trait RxObserver extends OnUnmount {
def observe[T](rx: Rx[T])(f: T ⇒ Unit) = {
val obs = rx foreach f
onUnmount(obs.kill())
}
}
object RxObserver {
trait CommonValueClass extends Any
class Type1 private(val name : String) extends CommonValueClass
object Type1 {
val SCALA = new Type1("scala")
}
class Type2 private(val option : String) extends CommonValueClass
case class Menu(name: String, route: AppPage)
object TopNav {
object Style extends StyleSheet.Inline {
import dsl._
val navMenu = style(display.flex,
alignItems.center,