{"action":"created","issue":{"url":"https://api.github.com/repos/Yomguithereal/baobab/issues/240","labels_url":"https://api.github.com/repos/Yomguithereal/baobab/issues/240/labels{/name}","comments_url":"https://api.github.com/repos/Yomguithereal/baobab/issues/240/comments","events_url":"https://api.github.com/repos/Yomguithereal/baobab/issues/240/events","html_url":"https://github.com/Yomguithereal/baobab/issues/240","id":79591089,"number":240,"title":"Facets are actually implementation leak","user":{"login":"ivan-kleshnin","id":2128182,"avatar_url":"https://avatars.githubusercontent.com/u/2128182?v=3","gravatar_id":"","url":"https://api.github.com/users/ivan-kleshnin","html_url":"https://github.com/ivan-kleshnin","followers_url":"https://api.github.com/users/ivan-kleshnin/followers","following_url":"https://api.github.com/users/ivan-kleshnin/following{/other_user}","gists_url":"https://api.github.com/users/ivan-kleshnin/gists{/gist_id}","starred_url":"https://api.github.com/users/ivan-kleshnin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivan-kleshnin/subscriptions","organizations_url":"https://api.github.com/users/ivan-kleshnin/orgs","repos_url":"https://api.github.com/users/ivan-kleshnin/repos","events_url":"https://api.github.com/users/ivan-kleshnin/events{/privacy}","received_events_url":"https://api.github.com/users/ivan-kleshnin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Yomguithereal/baobab/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/Yomguithereal/baobab/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":39,"created_at":"2015-05-22T20:08:29Z","updated_at":"2015-06-11T09:44:10Z","closed_at":null,"body":"I think about this thing... Facets described as \"views over data\". But the same thing may be said about cursors. They are also \"views over data\". The difference is that one data is \"static\" and other is \"dynamic\". But this means nothing. If we have `c = f(b)` rule we never conclude that `c` has different nature than `b`. Derived and initial data are expressed in the same syntax and are equal for the consumers. The whole Math and Computer Science are based on that.\r\n\r\nUnfortunately, this is not the case with facets. Client code must be aware of this artifical separation:\r\n```\r\nlet foo = state.facets.foo;\r\nvs\r\nlet foo = state.select(\"foo\").get()\r\n```\r\nor\r\n```\r\n@branch({\r\n  cursors: ...\r\n  vs \r\n  facets: ...\r\n})\r\n```\r\n\r\nThis seems wrong to me. I shouldn't be concerned about such private details of the data in the client code. Is it \"static\" or \"dynamic\"? I don't care. I shouldn't ask. But now the client code and implicit rules about our data are coupled and we can't simply switch between `a <- b` and `b <- a` causalities. This means implementation leak.\r\n\r\nUnless I miss something, I propose to think about merging cursor and facet concepts into one more powerful abstraction (keeping `cursor` name). So cursors may be expressed in terms of cursors and static data then.\r\n\r\nBut... saying that... I'm afraid that we actually reinvent the wheel here. \r\nThis issues @christianalfoni raised:\r\nhttps://github.com/Yomguithereal/baobab-react/issues/44\r\nhttps://github.com/Yomguithereal/baobab/issues/180\r\npush me even more to the thought that Baobab will benefit being built over smarter abstraction(s).\r\nEvent emitters are too primitive. We want to control initial states, we want to have movable parts having single app state at the same time. We want more and more complex primitives to express relations between data in facets like filters of all kinds...\r\n\r\nIt sounds like... RxJS Observables could handle this better. \r\nOr CSP channels. \r\n\r\nThere are attempts to bind React and Rx... with more or less luck.\r\nhttps://github.com/fdecampredon/rx-flux\r\nhttps://github.com/r3dm/thundercats\r\n\r\nNoone of them takes the concept of single app state, they are basically follow the Flux path having distinct Stores. But in everything else... we are moving to the same direction. Any state (including Baobab trees, of course) can be expressed in terms of temporal `reduce` function named `scan`. The difference between it and familiar `reduce` we used to is that this `scan` broadcasts every new state to the observers, not just returns one final data (because most of data sources *never* finish). I wonder if it's possible to just drop all that event emitter poor machinery and rebuilt everything on something more powerful and more suitable to our big big big list of requirements. Sounds scary, I know.\r\n\r\nI'd like to think I overcomplicate things and there is a well-defined outline of what Baobab should and shouldn't do. Somewhere. But I'm afraid I'm not.\r\n\r\n:camel: "},"comment":{"url":"https://api.github.com/repos/Yomguithereal/baobab/issues/comments/111068792","html_url":"https://github.com/Yomguithereal/baobab/issues/240#issuecomment-111068792","issue_url":"https://api.github.com/repos/Yomguithereal/baobab/issues/240","id":111068792,"user":{"login":"jacomyal","id":144846,"avatar_url":"https://avatars.githubusercontent.com/u/144846?v=3","gravatar_id":"","url":"https://api.github.com/users/jacomyal","html_url":"https://github.com/jacomyal","followers_url":"https://api.github.com/users/jacomyal/followers","following_url":"https://api.github.com/users/jacomyal/following{/other_user}","gists_url":"https://api.github.com/users/jacomyal/gists{/gist_id}","starred_url":"https://api.github.com/users/jacomyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacomyal/subscriptions","organizations_url":"https://api.github.com/users/jacomyal/orgs","repos_url":"https://api.github.com/users/jacomyal/repos","events_url":"https://api.github.com/users/jacomyal/events{/privacy}","received_events_url":"https://api.github.com/users/jacomyal/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T09:44:10Z","updated_at":"2015-06-11T09:44:10Z","body":"@Yomguithereal \r\n\r\n**Question n°1**\r\nI'd rather keep the **$** when calling Baobab's API - it looks less \"magic\" to me.\r\n\r\n**Question n°2**\r\nMaybe more something like `['$.', 'users']`, to keep the strings clean?\r\n\r\nAlso, the two advantages you identified totally make sense, and I understand better the benefits of unifying the API."}}