Fork me on GitHub

hi, using the firebase lib from cljsjs (aset (js/firebase.auth) "languageCode" "fr") expression does work when compiled with :advanced option.


firebase.auth.Auth.prototype.languageCode; appears, which i suppose the firebase wrapper in cljsjs uses


Hi @gadfly361, In re-pressed What will be the pattern for dispatching a key-press event that's mapping updates when the db updates ? My re-frame app is an interactive representation of the solar system. the visible elements (which are maps) as well as the attributes (keys and values) are selected interactively. The result is interpolated to sound and I manage to do this fine dispatching an on-change or on-hover event [:audio value1 value2]. I'd like to be able to dispatch this event with keys in the home row, so I made this vector key-vec [65 83 68 70 71 72 74 75 76 186 192 222 ] (key-code for home row) and I'm trying to map these on a set-keydown-rules with a for loop...

(defn keyboard []                                                                                                                               
  (let [selected-attr @(subscribe [::subs/selected-attr])                       ;the key whose values will be extracted from all selected maps                                                                
        spheres @(subscribe [::subs/sorted-spheres])                             ;the filtered list of maps                                                              
        adshr @(subscribe [::subs/envelope])                                           ;user defined first value for audio event                                                         
        key-vec [65 83 68 70 71 72 74 75 76 186 192 222 90]]          ;the keyboard's home row to be mapped                                                                          
    (for [body spheres :when (:vis body)]                                                                                                       
         [[:audio adshr (interpolate (selected-attr body))]                        ;interpolate is a function that will output the second required value for the audio event                                                             
            (nth key-vec (.indexOf spheres body))                                                                                               
Naive... I know ... What will work?


@adamgefen You will need to map the event-keys into a vector and then dispatch set-keydown-rules. set-keydown-rules is a replacement of the current rules instead of being addidtive


So your current for loop would only result with keydown rules for the last thing in the for loop


I'll give it a go. Thanks!

👍 5

perfect! I made the function:

(defn key-event-vec []                                                                                                                          
  (let [selected-attr @(subscribe [::subs/selected-attr])                                                                                       
        spheres @(subscribe [::subs/sorted-spheres])                                                                                            
        adshr @(subscribe [::subs/envelope])                                                                                                    
        key-vec [65 83 68 70 71 72 74 75 76 186 192 222 90]]                                                                                    
    {:event-keys (into [] (for [body spheres :when (:vis body)]                                                                                 
                            [[:audio adshr (interpolate (selected-attr body))]                                                                  
                             [{:keyCode (nth key-vec (.indexOf spheres body))}]]))}))                                                           
followed by:
(defn keyboard []                                                                                                                               
   [::rp/set-keydown-rules (key-event-vec)]))
brilliant! thanks.


Awesome! Np :)