clojure - How do I use core.match in Clojurescript with goog.events.KeyCodes? -


  (Edit mode-mode? [] "A hardcode (for moment) value will appear in DB later Goog.events.KeyCodes.Down (def LEFT 37) ;; Goog.events.KeyCodes.LEFT (def Write 39);; false; ; Goog.events.KeyCodes.RIGHT (def W 87) ;; Goog.events.KeyCodes.W (def S 83) ;; Goog.events.KeyCodes.S (def one 65) ;; Goog.events.KeyCodes.A (Def D68) ;; Goog.events.KeyCodes.D (def E69) ;; Goog.events.KeyCodes.E (def ESC 27) ;; Goog.events.KeyCodes.ESC (defan delta [e] ;; E A Google Closure Event (js / console.log (.-KeyCode e)) (js / console.log (editing-mode?)) (Match [[edit-mode?] (.- KeyCode e)] [false 38 ] [: Slide: top] [false 40] [: slide : [False] left: [false 37] [: false [left]] [false 39] [: slide [wrong] [false [87] [: slide: top] [false 83] [: slide: bottom] [false 65] [: Slide: left] [false 68] [: slide: right] [false 69] [: starting-therapy] [true 27] [: done-editing]: else zero))  

The code above works, however, if I try to be a bit less and straighten the use of gog keycode, then

  ([edit-mode?] (. ) [Wrong Gog. Events.KeyCodes.UP] [: slide: top] [wrong goog.events.keyCodes.DOWN] [: slide: bottom] ...  

I get the following cljsbuild error: < / P>

  ... done by: clojure.lang.ExceptionInfo: Invalid local name: goog.events.KeyCodes.UP ... ...  

OK, so I goog.events.KeyCodes * can not use themselves, but perhaps I can use a ref referred to them? Then I try

  ([edit-mode?] (.- key code E)] [false UP] [: slide: top] [false bottom] [: slide: bottom] ...  

It compiles, but now the match is not just working. Every major event matches [false UP] (core. Matches always [: slide: up] ).

However, the first code example works. But I goog.events.KeyCodes. * Why can not use context or goog.events.KeyCodes. * my core.match matcher Is there something that I'm missing?

core.match This will be bound to values ​​rather than matching, that is, the current value of UP was not seen and used in the match; instead, the symbol UP is bound to value (.- keyCode e) when is incorrect matches.

Unfortunately From, as I know, there is nothing that is missing You can do this with core.match . It is very much dependent on literal values, however, your pattern is quite simple, so you (conp = ...) .

.

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -