We're using lacinia for the subscriptions, and currently, we're using an atom for updating the changes where the streamer keeps an eye on it and streams the changes whenever the atom is updated. Now to how to replace the atom with pub/sub feature?
defonce mid (atom nil))
(defn update-app-data
[_ _ {:keys [id bio]} _]
(update-data id {:bio bio})
(reset! mid[:bio bio]) ;;updates the atom with bio
)
(defn app-streamer
[_ _ {:keys [id title]} source-stream]
(let [generated-key (gensym "app streamer")]
(add-watch mid generated-key ;;checks the atom for changes in title
(fn [_ _ _ [a bio :as new-state]]
(when (= :bio a)
(source-stream (get-app-data id)))
(fn [] (remove-watch mid generated-key))))))
We're using lacinia for the subscriptions, and currently, we're using an atom for updating the changes where the streamer keeps an eye on it and streams the changes whenever the atom is updated. Now to how to replace the atom with pub/sub feature?