{"action":"closed","issue":{"url":"https://api.github.com/repos/EventStore/EventStore/issues/578","labels_url":"https://api.github.com/repos/EventStore/EventStore/issues/578/labels{/name}","comments_url":"https://api.github.com/repos/EventStore/EventStore/issues/578/comments","events_url":"https://api.github.com/repos/EventStore/EventStore/issues/578/events","html_url":"https://github.com/EventStore/EventStore/issues/578","id":99050433,"number":578,"title":"How to access my projection state from code?","user":{"login":"plato-cambrian","id":7917920,"avatar_url":"https://avatars.githubusercontent.com/u/7917920?v=3","gravatar_id":"","url":"https://api.github.com/users/plato-cambrian","html_url":"https://github.com/plato-cambrian","followers_url":"https://api.github.com/users/plato-cambrian/followers","following_url":"https://api.github.com/users/plato-cambrian/following{/other_user}","gists_url":"https://api.github.com/users/plato-cambrian/gists{/gist_id}","starred_url":"https://api.github.com/users/plato-cambrian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plato-cambrian/subscriptions","organizations_url":"https://api.github.com/users/plato-cambrian/orgs","repos_url":"https://api.github.com/users/plato-cambrian/repos","events_url":"https://api.github.com/users/plato-cambrian/events{/privacy}","received_events_url":"https://api.github.com/users/plato-cambrian/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-04T20:04:41Z","updated_at":"2015-08-05T05:59:46Z","closed_at":"2015-08-05T05:59:46Z","body":"I am loving eventstore as a sensible way to organize many streams of data! I'm working on refactoring my ACL code. I currently store everything in one database document but I'd like to instead keep track of the individual events that are used to assemble that document.\r\n\r\nI have created one stream, `authAcl`, and I emit three types of events to the stream. I have made a projection that assembles a denormalized representation of my ACL rules in its state object:\r\n\r\n    fromStream('authAcl')\r\n    .when({\r\n        '$init': function(state, event){\r\n            return {\r\n                rolePermissions: [],\r\n                roleParents: [],\r\n                userRoles: [],\r\n            }\r\n        },\r\n        'auth.aclAddPermission': function(state, event){\r\n            var item = [event.data.role, event.data.endpoint, event.data.action];\r\n            state.rolePermissions.push(item);\r\n            return state;\r\n        },\r\n        'auth.aclCascadePermissions': function(state, event){ ... },\r\n        'auth.aclGrantRole': function(state, event){ ... },\r\n    })\r\n\r\nMy web UI shows the result I expect, an object with `rolePermissions`, `roleParents`, `userRoles` arrays. Now I need to use this state and subscribe to updates from my code. The only approach I can think of now is to create a new `aclRulesFlattened` stream and emit the flattened state to it every time my projection changes it.\r\n\r\nIs there built in functionality to get the state of a projection as a stream?\r\nIs there an HTTP API call to get the state of a projection?\r\nIs there an TCP API call to get the state of a projection?"}}