Fork me on GitHub
#cljsrn
<
2020-06-25
>
benny15:06:21

i’m assuming headless js is the way to keep a web socket open when my app is in the background, but it looks like headless is moreso triggered by an event. any guidance how to “continue” a web socket from foreground to background?e

lepistane17:06:53

this has been driving me nuts. Did anyone encounter this? i am trying to recreate example https://github.com/wuxudong/react-native-charts-wrapper/blob/master/Example/app/LiveUpdateChartScreen.js and this is my component

(defn line-chart []
  (let [values (rf/subscribe [:graph/data :line])
        colors [(rn/processColor "red") (rn/processColor "blue") (rn/processColor "green") (rn/processColor "yellow") (rn/processColor "purple") (rn/processColor "pink")]]
    [:> rn/View {:flex 7}
     (prn @values)
     [:> charts/LineChart {:style {:flex 1
                                   :background-color :red}
                           :data (clj->js {:dataSets [{:values @values
                                                       :label "A"
                                                       :config {:lineWidth 2
                                                                :drawValues false
                                                                :dashedLine {:lineLength 10
                                                                             :spaceLength 10
                                                                             :phase 0}
                                                                :color (get colors (rand-int 6))}
                                                       }]})


                           }]])

 
  )
The color of line is updated properly (every 15 sec when @value changes) but data is not shown on the graph until 4-5 updates pass and then all of sudden all appear i've inspected props by using refs and those are updated accordingly but rerender doesn't happen i tried implmenting wrapper similar to https://gist.github.com/jhchabran/e09883c3bc1b703a224d and setState manually - nothing worked does anyone have any idea how i could go about this? I just need to force rerender when @value is updated (which btw is vector of maps with :x and :y)