{"action":"opened","issue":{"url":"https://api.github.com/repos/angular/angularfire2/issues/357","repository_url":"https://api.github.com/repos/angular/angularfire2","labels_url":"https://api.github.com/repos/angular/angularfire2/issues/357/labels{/name}","comments_url":"https://api.github.com/repos/angular/angularfire2/issues/357/comments","events_url":"https://api.github.com/repos/angular/angularfire2/issues/357/events","html_url":"https://github.com/angular/angularfire2/issues/357","id":165568935,"number":357,"title":"Working with FirebaseObjectObservable results inside functions","user":{"login":"flowdee","id":2278756,"avatar_url":"https://avatars.githubusercontent.com/u/2278756?v=3","gravatar_id":"","url":"https://api.github.com/users/flowdee","html_url":"https://github.com/flowdee","followers_url":"https://api.github.com/users/flowdee/followers","following_url":"https://api.github.com/users/flowdee/following{/other_user}","gists_url":"https://api.github.com/users/flowdee/gists{/gist_id}","starred_url":"https://api.github.com/users/flowdee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flowdee/subscriptions","organizations_url":"https://api.github.com/users/flowdee/orgs","repos_url":"https://api.github.com/users/flowdee/repos","events_url":"https://api.github.com/users/flowdee/events{/privacy}","received_events_url":"https://api.github.com/users/flowdee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-14T13:59:45Z","updated_at":"2016-07-14T13:59:45Z","closed_at":null,"body":"I want to fetch data from firebase, work with it (manipulating) inside multiple functions and later writing it back to the database. My DB looks like this:\r\n\r\n```json\r\n{\r\n  \"indices\": {\r\n    \"announcements\": 5,\r\n    \"products\": 12,\r\n    \"requests\": 13,\r\n    \"users\": 3\r\n  }\r\n} \r\n```\r\n\r\nInside a component I included the following service and call the `getIndex` function and passing a type name (in this example \"requests\"):\r\n\r\n```ts\r\nprivate index = 0;\r\n\r\nindices: FirebaseObjectObservable<any>;\r\n\r\nconstructor(public af: AngularFire) {\r\n    this.indices = af.database.object('/indices');\r\n}\r\n\r\ngetIndex( type: string ) {\r\n\r\n    this.indices.subscribe(snapshot => {\r\n        console.log('Snapshot type result: ' + snapshot[type]);\r\n        //this.index = snapshot[type];\r\n        this.index = snapshot.requests;\r\n    });\r\n\r\n    return this.index;\r\n}\r\n```\r\n\r\nBut how do I pass the value out of the data? When doing a `console.log(snapshot.requests)` inside the `subscribe` function it will output **13** but I don't want to log it **I want to forward this value to other functions** etc. and DON'T output on frontend with pipe async etc."}}
{"actor":{"display_login":"flowdee"}}