I am trying to refactor this code to use if-let:
om/IWillMount
(will-mount [_]
(go (while true
(if (om/get-state owner :is-loaded)
(let [updated-world (<! (update-world (:dimensions opts) (:world @data)))]
(om/transact! data #(assoc % :world updated-world))
(swap! app-state assoc :world updated-world))
(let [world (<! (get-world (:dimensions opts)))]
(om/set-state! owner :is-loaded true)
(om/transact! data #(assoc % :world world))
(swap! app-state assoc :world world)))
(<! (timeout (:poll-interval opts))))))
So far I have tried this:
om/IWillMount
(will-mount [_]
(go (while true
(if-let [world (om/get-state owner :is-loaded)]
(<! (update-world (:dimensions opts) (:world @data)))
(<! (get-world (:dimensions opts)))
(om/set-state! owner :is-loaded true)
(om/transact! data #(assoc % :world world))
(swap! app-state assoc :world world))
(<! (timeout (:poll-interval opts))))))
But I get this error:
Caused by: java.lang.IllegalArgumentException: if-let requires 1 or 2 forms after binding vector in web-game-of-life.app:58