{"action":"created","issue":{"url":"https://api.github.com/repos/denistakeda/re-posh/issues/13","repository_url":"https://api.github.com/repos/denistakeda/re-posh","labels_url":"https://api.github.com/repos/denistakeda/re-posh/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/denistakeda/re-posh/issues/13/comments","events_url":"https://api.github.com/repos/denistakeda/re-posh/issues/13/events","html_url":"https://github.com/denistakeda/re-posh/issues/13","id":265578381,"number":13,"title":"Support combined pull and query in a subscription","user":{"login":"sdaros","id":7618462,"avatar_url":"https://avatars3.githubusercontent.com/u/7618462?v=4","gravatar_id":"","url":"https://api.github.com/users/sdaros","html_url":"https://github.com/sdaros","followers_url":"https://api.github.com/users/sdaros/followers","following_url":"https://api.github.com/users/sdaros/following{/other_user}","gists_url":"https://api.github.com/users/sdaros/gists{/gist_id}","starred_url":"https://api.github.com/users/sdaros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdaros/subscriptions","organizations_url":"https://api.github.com/users/sdaros/orgs","repos_url":"https://api.github.com/users/sdaros/repos","events_url":"https://api.github.com/users/sdaros/events{/privacy}","received_events_url":"https://api.github.com/users/sdaros/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-10-15T15:01:39Z","updated_at":"2018-03-06T17:17:25Z","closed_at":null,"author_association":"NONE","body":"It would be really handy to be able to combine a pull and query in a subscription like you can in datascript. Assuming you want to retrieve all entity attributes for a particular product containing the unique attribute `:inv/sku`, it could look something like this:\r\n\r\n```clojure\r\n(re-posh/reg-pull-sub\r\n :item-by-sku\r\n (fn [ds [_ sku]]\r\n   (datascript.core/pull '[*] (datascript.core/q '[:find ?e\r\n                                                   :in $ ?sku\r\n                                                   :where\r\n                                                   [?e :inv/sku ?sku]] ds) ds)))\r\n```"},"comment":{"url":"https://api.github.com/repos/denistakeda/re-posh/issues/comments/370857426","html_url":"https://github.com/denistakeda/re-posh/issues/13#issuecomment-370857426","issue_url":"https://api.github.com/repos/denistakeda/re-posh/issues/13","id":370857426,"user":{"login":"denistakeda","id":6669339,"avatar_url":"https://avatars0.githubusercontent.com/u/6669339?v=4","gravatar_id":"","url":"https://api.github.com/users/denistakeda","html_url":"https://github.com/denistakeda","followers_url":"https://api.github.com/users/denistakeda/followers","following_url":"https://api.github.com/users/denistakeda/following{/other_user}","gists_url":"https://api.github.com/users/denistakeda/gists{/gist_id}","starred_url":"https://api.github.com/users/denistakeda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denistakeda/subscriptions","organizations_url":"https://api.github.com/users/denistakeda/orgs","repos_url":"https://api.github.com/users/denistakeda/repos","events_url":"https://api.github.com/users/denistakeda/events{/privacy}","received_events_url":"https://api.github.com/users/denistakeda/received_events","type":"User","site_admin":false},"created_at":"2018-03-06T17:17:25Z","updated_at":"2018-03-06T17:17:25Z","author_association":"OWNER","body":"@rafd Looks good, but it breaks the API. I would add the two options for this function, for one argument and for two:\r\n```clojure\r\n(defn reg-pull-sub\r\n  ([sub-name pull-pattern]\r\n   (reg-sub-row sub-name\r\n       (fn [_ [_ id]]\r\n          (p/pull @store pattern id))))\r\n  ([sub-name query-pattern pull-pattern]\r\n  (reg-sub-raw sub-name\r\n    (fn [_ [_ & args]]\r\n      ; result should be: id, nil, [id id ...] or []\r\n      (let [result (apply p/q query-pattern @store args)]\r\n        (cond\r\n          (vector? @result) ; [id id ...] or []\r\n          (->> @result\r\n               (map (fn [id]\r\n                      @(p/pull @store pull-pattern id)))\r\n               r/reaction)\r\n\r\n          (some? @result) ; id\r\n          (p/pull @store pull-pattern @result)\r\n\r\n          :else ; nil\r\n          result))))))\r\n```\r\n\r\nWould you mind to create PR or I can do it myself later?\r\n\r\nAlso, I was thinking of creating a new function with API similar to re-frame [reg-sub](https://github.com/Day8/re-frame/blob/cf44443d0e2fc5009677e8082c3a6657b8a64e0c/src/re_frame/subs.cljc#L200)"}}
{"actor":{"display_login":"denistakeda"}}