{"action":"created","issue":{"url":"https://api.github.com/repos/scalajs-react-interface/sri/issues/11","repository_url":"https://api.github.com/repos/scalajs-react-interface/sri","labels_url":"https://api.github.com/repos/scalajs-react-interface/sri/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/scalajs-react-interface/sri/issues/11/comments","events_url":"https://api.github.com/repos/scalajs-react-interface/sri/issues/11/events","html_url":"https://github.com/scalajs-react-interface/sri/issues/11","id":294261944,"number":11,"title":"How to define a function of type js.Dynamic => _ ?","user":{"login":"akiradeveloper","id":785824,"avatar_url":"https://avatars2.githubusercontent.com/u/785824?v=4","gravatar_id":"","url":"https://api.github.com/users/akiradeveloper","html_url":"https://github.com/akiradeveloper","followers_url":"https://api.github.com/users/akiradeveloper/followers","following_url":"https://api.github.com/users/akiradeveloper/following{/other_user}","gists_url":"https://api.github.com/users/akiradeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/akiradeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akiradeveloper/subscriptions","organizations_url":"https://api.github.com/users/akiradeveloper/orgs","repos_url":"https://api.github.com/users/akiradeveloper/repos","events_url":"https://api.github.com/users/akiradeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/akiradeveloper/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-02-05T03:13:42Z","updated_at":"2018-02-09T03:12:38Z","closed_at":"2018-02-09T03:12:38Z","author_association":"NONE","body":"This is an example code to flip a colored rectangle when the button is pressed but still in error when running on emulator. What's wrong with my code?\r\n\r\n```scala\r\nobject Experimental {\r\n  case class State(\r\n    angleAnim: AnimatedValue = new AnimatedValue(0)\r\n  )\r\n  class Component extends NavigationScreenComponentS[State] {\r\n    initialState(State())\r\n    var angle: Double = 0\r\n    def render() = {\r\n      import styles._\r\n      val onPressHandler = () => {\r\n        state.angleAnim.setValue(angle)\r\n        Animated.timing(\r\n          this.state.angleAnim,\r\n          new TimingAnimationConfig {\r\n            toValue = angle + 180\r\n            duration = 1000 // ms?\r\n          }\r\n        ).start()\r\n      }\r\n      View(style = whole)(\r\n        AnimatedView(style = tile(angle))(),\r\n        Button(title = \"flip\", onPress = onPressHandler)\r\n      )\r\n    }\r\n    val callbackFun = (x: js.Dynamic) => {\r\n      // angle = x.asInstanceOf[Double]\r\n    }\r\n    override def componentDidMount(): Unit = {\r\n      state.angleAnim.addListener(callbackFun)\r\n    }\r\n  }\r\n  object styles extends InlineStyleSheetUniversal {\r\n    import dsl._\r\n    val whole = style(\r\n      flex := 1,\r\n      alignItems.center\r\n    )\r\n    def tile(angle: Double) = style(\r\n      width := 100,\r\n      height := 100,\r\n      backgroundColor := (if (90 <= angle && angle < 270) \"blue\" else \"red\"),\r\n      transform := js.Array(\r\n        js.Dynamic.literal(rotateX = s\"${angle}deg\")\r\n      )\r\n    )\r\n  }\r\n}\r\n```\r\n\r\n![2018-02-05 12 07 29](https://user-images.githubusercontent.com/785824/35786801-2ac45bb8-0a6d-11e8-94f5-7773cd23b03f.png)\r\n\r\nThe error says, I guess, the function I passed isn't a function. But it's compiled and I can't see anything wrong.\r\n\r\n![2018-02-05 12 01 10](https://user-images.githubusercontent.com/785824/35786778-fd980248-0a6c-11e8-9eea-8dddc3e97c47.png)\r\n\r\nHere is what is generated by Scala.js, related to the callback function.\r\n\r\n```js\r\nfunction $s_Le9_default_Experimental$Component__componentDidMount__Le9_default_Experimental$Component__V($this) {\r\n  $as_Le9_default_Experimental$State($this.scalaState).angleAnim$1.addListener($as_F1($this.callbackFun))\r\n}\r\n...\r\nfunction $s_Le9_default_Experimental$Component__$$anonfun$callbackFun$1__p6__Le9_default_Experimental$Component__sjs_js_Dynamic__V($this, x) {\r\n  /*<skip>*/\r\n}\r\nvar $b_Le9_default_Experimental$Component = (void 0);\r\nfunction $a_Le9_default_Experimental$Component() {\r\n  if ((!$b_Le9_default_Experimental$Component)) {\r\n    /** @constructor */\r\n    var $c_Le9_default_Experimental$Component = (function $c_Le9_default_Experimental$Component() {\r\n      $a_Lsri_navigation_NavigationScreenComponentS().call(this, $m_Lsri_core_package$().neq__Lsri_core_package$$eq$colon$bang$eq());\r\n      Object.defineProperty(this, \"angle\", {\r\n        \"configurable\": true,\r\n        \"enumerable\": true,\r\n        \"writable\": true,\r\n        \"value\": 0.0\r\n      });\r\n      Object.defineProperty(this, \"callbackFun\", {\r\n        \"configurable\": true,\r\n        \"enumerable\": true,\r\n        \"writable\": true,\r\n        \"value\": null\r\n      });\r\n      this.initialState(new $c_Le9_default_Experimental$State($m_Le9_default_Experimental$State$().apply$default$1__Lsri_universal_apis_AnimatedValue()));\r\n      this.angle = 0.0;\r\n      this.callbackFun = new $c_sjsr_AnonFunction1((function($this) {\r\n        return (function(x$2) {\r\n          var x = x$2;\r\n          $s_Le9_default_Experimental$Component__$$anonfun$callbackFun$1__p6__Le9_default_Experimental$Component__sjs_js_Dynamic__V($this, x)\r\n        })\r\n      })(this))\r\n    });\r\n```"},"comment":{"url":"https://api.github.com/repos/scalajs-react-interface/sri/issues/comments/364322830","html_url":"https://github.com/scalajs-react-interface/sri/issues/11#issuecomment-364322830","issue_url":"https://api.github.com/repos/scalajs-react-interface/sri/issues/11","id":364322830,"user":{"login":"chandu0101","id":2179670,"avatar_url":"https://avatars0.githubusercontent.com/u/2179670?v=4","gravatar_id":"","url":"https://api.github.com/users/chandu0101","html_url":"https://github.com/chandu0101","followers_url":"https://api.github.com/users/chandu0101/followers","following_url":"https://api.github.com/users/chandu0101/following{/other_user}","gists_url":"https://api.github.com/users/chandu0101/gists{/gist_id}","starred_url":"https://api.github.com/users/chandu0101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chandu0101/subscriptions","organizations_url":"https://api.github.com/users/chandu0101/orgs","repos_url":"https://api.github.com/users/chandu0101/repos","events_url":"https://api.github.com/users/chandu0101/events{/privacy}","received_events_url":"https://api.github.com/users/chandu0101/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T03:12:38Z","updated_at":"2018-02-09T03:12:38Z","author_association":"OWNER","body":"published `2018.2.9-RC`"}}
{"actor":{"display_login":"chandu0101"}}