{"action":"created","issue":{"url":"https://api.github.com/repos/aaronc/freactive/issues/33","labels_url":"https://api.github.com/repos/aaronc/freactive/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/aaronc/freactive/issues/33/comments","events_url":"https://api.github.com/repos/aaronc/freactive/issues/33/events","html_url":"https://github.com/aaronc/freactive/issues/33","id":53233563,"number":33,"title":"Possible bug: watches are dropped","user":{"login":"davesann","id":719090,"avatar_url":"https://avatars.githubusercontent.com/u/719090?v=3","gravatar_id":"","url":"https://api.github.com/users/davesann","html_url":"https://github.com/davesann","followers_url":"https://api.github.com/users/davesann/followers","following_url":"https://api.github.com/users/davesann/following{/other_user}","gists_url":"https://api.github.com/users/davesann/gists{/gist_id}","starred_url":"https://api.github.com/users/davesann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davesann/subscriptions","organizations_url":"https://api.github.com/users/davesann/orgs","repos_url":"https://api.github.com/users/davesann/repos","events_url":"https://api.github.com/users/davesann/events{/privacy}","received_events_url":"https://api.github.com/users/davesann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-02T01:14:15Z","updated_at":"2015-01-02T02:40:29Z","closed_at":null,"body":"I have been investigating freactive and came across the following - which appears to be a bug.\r\n\r\nI was testing out cursors and compound state access in rx.\r\n\r\nI created a \"complex-state\" that included a mouse position and time.\r\nmouse position is updated on mouse move\r\ntime is updated by a setInterval.\r\n\r\nThe bug appears to be that the watch on the time state or cursor is lost when the mouse is moved. i.e the reactions on time-cursor work but then stop when the mouse is moved.\r\n\r\nAnother thing that I noticed was that repeatedly calling (rdom/mount! root (view)) will keep adding watches. Many more that would seem necessary if mount is replacing the view.\r\n\r\nAre these errors on my part - or is there an issue here?\r\n\r\n\r\nCode below:\r\n\r\n```clojure\r\n(ns test-freactive\r\n  (:require \r\n    [freactive.core :as rc]\r\n    [freactive.dom  :as rdom]\r\n    )\r\n  (:require-macros\r\n    [freactive.macros :refer [debug-rx rx]]))\r\n\r\n(enable-console-print!)\r\n\r\n(defn now []\r\n  (.getTime (js/Date.)))\r\n\r\n\r\n(defonce root (rdom/append-child! (.-body js/document) [:div#root]))\r\n\r\n\r\n(defonce independent-time-state (rc/atom {:time nil}))\r\n\r\n(defonce complex-state (rc/atom {:mouse-pos nil\r\n                                 :time nil}))\r\n\r\n(defonce mouse-pos-cursor  (rc/cursor complex-state [:mouse-pos]))\r\n(defonce time-cursor (rc/cursor complex-state [:time]))\r\n(defonce schedule-cursor   (rc/cursor complex-state [:interval]))\r\n\r\n                              \r\n(defn update-time! []\r\n  (reset! time-cursor (now))\r\n  (reset! independent-time-state {:time (now)})\r\n  #_(swap! complex-state update-in [:time] (fn [_] (now))))\r\n\r\n(defn schedule []\r\n  (when-let [interval @schedule-cursor]\r\n    (js/clearInterval interval))\r\n  (let [interval (js/setInterval update-time! 100)] \r\n    (reset! schedule-cursor interval)))\r\n\r\n(defn view []\r\n  [:div\r\n   {:width \"100%\" :height \"100%\" :style {:border \"1px solid black\"}\r\n    :on-mousemove (fn [e] (reset! mouse-pos-cursor [(.-clientX e) (.-clientY e)]))}\r\n   [:h1 \"Hello World!\"]\r\n   #_[:p \"Your mouse is at: \" (rx (str @mouse-pos-cursor (now)))]\r\n   [:p \"Basic Time is: \"        (rx \r\n                                 (str @independent-time-state))]\r\n   \r\n   [:p \"cursor Time is: \"        (rx \r\n                                  (str @time-cursor))]\r\n   \r\n  #_ [:p \"lookup time is: \"      (rx (str (:time @complex-state)))]\r\n   \r\n   \r\n   \r\n   (rx [:div \r\n        [:p \"full-state  is:\" (str @complex-state)]\r\n        [:p \"num watches on full state: \" (str (count (.-watches complex-state)))]\r\n        [:p \"num watches on time update cursor: \" (str (count (.-watches time-cursor)))]])\r\n    \r\n   ])\r\n\r\n(defn go-freactive []\r\n  (rdom/mount! root (view)))\r\n\r\n(schedule)\r\n(go-freactive)\r\n\r\n\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/aaronc/freactive/issues/comments/68506276","html_url":"https://github.com/aaronc/freactive/issues/33#issuecomment-68506276","issue_url":"https://api.github.com/repos/aaronc/freactive/issues/33","id":68506276,"user":{"login":"davesann","id":719090,"avatar_url":"https://avatars.githubusercontent.com/u/719090?v=3","gravatar_id":"","url":"https://api.github.com/users/davesann","html_url":"https://github.com/davesann","followers_url":"https://api.github.com/users/davesann/followers","following_url":"https://api.github.com/users/davesann/following{/other_user}","gists_url":"https://api.github.com/users/davesann/gists{/gist_id}","starred_url":"https://api.github.com/users/davesann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davesann/subscriptions","organizations_url":"https://api.github.com/users/davesann/orgs","repos_url":"https://api.github.com/users/davesann/repos","events_url":"https://api.github.com/users/davesann/events{/privacy}","received_events_url":"https://api.github.com/users/davesann/received_events","type":"User","site_admin":false},"created_at":"2015-01-02T02:40:29Z","updated_at":"2015-01-02T02:40:29Z","body":"That has resolved the issue.\r\n\r\nI do get compile errors with the snapshot though.\r\n\r\nWARNING: Use of undeclared Var freactive.core/this at line 383 ... freactive-0.2.0-SNAPSHOT.jar!/freactive/core.cljs\r\nWARNING: Wrong number of args (4) passed to freactive.dom/bind-attr! at line 422 freactive-0.2.0-SNAPSHOT.jar!/freactive/dom.cljs\r\n\r\nI did notice that the number of watches varies - this could be due to when they are being re-rendered. The update cursor is generally 1 but goes from 1 to 0 and back (this seems reasonable). the full state is generally 4 but jumps up and sown to to 5 when moving the mouse - that looked a little suspicious. But there may be a good reason.\r\n\r\nI checked the repeated call of mount and that was also resolved.\r\n\r\nWhen do you plan a 0.2.0 release?\r\n\r\nThanks\r\n\r\n\r\n\r\n\r\n"}}