{"action":"created","issue":{"url":"https://api.github.com/repos/ionic-team/ionic/issues/15855","repository_url":"https://api.github.com/repos/ionic-team/ionic","labels_url":"https://api.github.com/repos/ionic-team/ionic/issues/15855/labels{/name}","comments_url":"https://api.github.com/repos/ionic-team/ionic/issues/15855/comments","events_url":"https://api.github.com/repos/ionic-team/ionic/issues/15855/events","html_url":"https://github.com/ionic-team/ionic/issues/15855","id":366973764,"node_id":"MDU6SXNzdWUzNjY5NzM3NjQ=","number":15855,"title":"[4.0.0-beta.12] - - View sometimes doesn’t update on data change from subscribe","user":{"login":"bkarv","id":10624315,"node_id":"MDQ6VXNlcjEwNjI0MzE1","avatar_url":"https://avatars0.githubusercontent.com/u/10624315?v=4","gravatar_id":"","url":"https://api.github.com/users/bkarv","html_url":"https://github.com/bkarv","followers_url":"https://api.github.com/users/bkarv/followers","following_url":"https://api.github.com/users/bkarv/following{/other_user}","gists_url":"https://api.github.com/users/bkarv/gists{/gist_id}","starred_url":"https://api.github.com/users/bkarv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkarv/subscriptions","organizations_url":"https://api.github.com/users/bkarv/orgs","repos_url":"https://api.github.com/users/bkarv/repos","events_url":"https://api.github.com/users/bkarv/events{/privacy}","received_events_url":"https://api.github.com/users/bkarv/received_events","type":"User","site_admin":false},"labels":[{"id":835668554,"node_id":"MDU6TGFiZWw4MzU2Njg1NTQ=","url":"https://api.github.com/repos/ionic-team/ionic/labels/triage","name":"triage","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-04T21:16:04Z","updated_at":"2018-11-11T11:40:58Z","closed_at":"2018-11-11T11:40:58Z","author_association":"NONE","body":"# Bug Report\r\n\r\n**Ionic Info**\r\nRun `ionic info` from a terminal/cmd prompt and paste the output below.\r\n\r\n```\r\nIonic:\r\n\r\n   ionic (Ionic CLI)          : 4.2.0 (/usr/local/lib/node_modules/ionic)\r\n   Ionic Framework            : @ionic/angular 4.0.0-beta.12\r\n   @angular-devkit/core       : 0.9.0-beta.3\r\n   @angular-devkit/schematics : 0.9.0-beta.3\r\n   @angular/cli               : 6.1.5\r\n   @ionic/ng-toolkit          : 1.1.0\r\n   @ionic/schematics-angular  : 1.0.7\r\n\r\nCordova:\r\n\r\n   cordova (Cordova CLI) : 7.1.0\r\n   Cordova Platforms     : none\r\n   Cordova Plugins       : no whitelisted plugins (5 plugins total)\r\n\r\nSystem:\r\n\r\n   ios-deploy : 1.9.1\r\n   NodeJS     : v10.10.0 (/usr/local/bin/node)\r\n   npm        : 6.4.1\r\n   OS         : macOS High Sierra\r\n```\r\n\r\n**Describe the Bug**\r\nI am getting a very weird error in Ionic 4 where my view doesn’t update automatically when the data changes via a API subscribe response. However after the API has pulled the new data if I then click on the html view the data updates (almost like I am setting focus to the html view).\r\n\r\nThe issue with the error is very inconsistent and hard to replicate. But it now has happened twice to me when migrating my components.\r\n\r\nA bit of background I have a component that displays the role hierarchy of an organisation. Below is what the data object looks like. It is a nested objects.\r\n\r\n```\r\nlet obj1: OrganisationRoleChart = {\r\n      id: \"59f4d75d-5dd3-401c-a313-572efb266aec\",\r\n      organisation: {id: \"e36d1d62-c7ab-498d-8fc9-c674b7eb6b23\", name: \"ABCCOMPANY\", \r\norganisation_type: {id: 10, name: \"SUPPLIER\"}, default_folder: null},\r\n      role: {id: 2, name: \"CEO\", description: \"Head of finance\", is_protected: false},\r\n      description: null,\r\n\r\n        children: [{id: \"c1688286-2eeb-4c32-901e-f00788b31b5d\",\r\n           organisation: {id: \"e36d1d62-c7ab-498d-8fc9-c674b7eb6b23\", name: \"ABCCOMPANY\", \r\n           organisation_type: {id: 10, name: \"SUPPLIER\"}, default_folder: null},\r\n           role: {id: 3, name: \"Accountant\", description: \"Account dept\", is_protected: false},\r\n           description: null,\r\n\r\n          children: []}]\r\n    }\r\n```\r\n\r\n<img width=\"452\" alt=\"screen shot 2018-10-04 at 8 19 41 pm\" src=\"https://user-images.githubusercontent.com/10624315/46502930-b5fbc780-c86c-11e8-9754-8b0d4e034b05.png\">\r\n\r\nWhen I make a change like removing a role, it performs the action and the calls an API which is part of shared service to retrieve the updated role chart as below.\r\n\r\n```\r\n/*\r\n  ** name: Set Record\r\n  ** desc: \r\n  */\r\n  setRecord(): void {\r\n    this.isLoad = true;\r\n    this.presentLoading('Fetching...');\r\n    console.log('Fetching role chart...');\r\n    this.roleResourceService.getOrganisationRolesChartsHttp(this.id)\r\n    .subscribe(\r\n      data => { \r\n        console.log('Role charts fetched!', data);\r\n        if (data.length > 0) {\r\n          this.record = data[0];\r\n        } else {\r\n          this.record = null;\r\n        }      \r\n        this.dismissLoading();\r\n        this.isLoad = false;\r\n      },\r\n      err => {\r\n        this.events.publish('alert:server-error', err);              \r\n        this.dismissLoading();\r\n        this.isLoad = false;\r\n      },\r\n      () => console.log('Request Complete')\r\n    );\r\n```\r\n**The issue is when the new data is retrieved the view doesn’t update with the new hierarchy. But the weird thing is after pulling the new data when I click on the component area in the html view it then updates with the latest changes.**\r\n\r\nI did some further testing and made a simple button which manually changes the record. This works and the view updates as expected.\r\n\r\n```\r\ntest(): void {\r\n    let obj1: OrganisationRoleChart = {\r\n      id: \"59f4d75d-5dd3-401c-a313-572efb266aec\",\r\n      organisation: {id: \"e36d1d62-c7ab-498d-8fc9-c674b7eb6b23\", name: \"ABCCOMPANY\", organisation_type: {id: 10, name: \"SUPPLIER\"}, default_folder: null},\r\n      role: {id: 2, name: \"CEO\", description: \"Head of finance\", is_protected: false},\r\n      description: null,\r\n         children: [{id: \"c1688286-2eeb-4c32-901e-f00788b31b5d\",\r\n          organisation: {id: \"e36d1d62-c7ab-498d-8fc9-c674b7eb6b23\", name: \"ABCCOMPANY\", \r\n          organisation_type: {id: 10, name: \"SUPPLIER\"}, default_folder: null},\r\n          role: {id: 3, name: \"Accountant\", description: \"Account dept\", is_protected: false},\r\n          description: null,\r\n      children: []}]\r\n    }\r\n    this.record = obj1;\r\n  }\r\n```\r\nSo I am absolutely lost why is this happening, is as if the view component is loosing focus when it is does the API call. Has anyone else run into a similar issue? Appreciate any help on this.\r\n\r\n**Steps to Reproduce**\r\nThis is the issue, the error is so inconsistent it is very hard to reproduce. All I can determine in the above scenario it seems to be happening when I use the API subsribe. \r\n\r\nJust to reiterate this code worked without any issues in Ionic 3 so there is some underlying bug in Ionic 4 causing this issue. \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ionic-team/ionic/issues/comments/437663074","html_url":"https://github.com/ionic-team/ionic/issues/15855#issuecomment-437663074","issue_url":"https://api.github.com/repos/ionic-team/ionic/issues/15855","id":437663074,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzY2MzA3NA==","user":{"login":"bkarv","id":10624315,"node_id":"MDQ6VXNlcjEwNjI0MzE1","avatar_url":"https://avatars0.githubusercontent.com/u/10624315?v=4","gravatar_id":"","url":"https://api.github.com/users/bkarv","html_url":"https://github.com/bkarv","followers_url":"https://api.github.com/users/bkarv/followers","following_url":"https://api.github.com/users/bkarv/following{/other_user}","gists_url":"https://api.github.com/users/bkarv/gists{/gist_id}","starred_url":"https://api.github.com/users/bkarv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkarv/subscriptions","organizations_url":"https://api.github.com/users/bkarv/orgs","repos_url":"https://api.github.com/users/bkarv/repos","events_url":"https://api.github.com/users/bkarv/events{/privacy}","received_events_url":"https://api.github.com/users/bkarv/received_events","type":"User","site_admin":false},"created_at":"2018-11-11T11:40:58Z","updated_at":"2018-11-11T11:40:58Z","author_association":"NONE","body":"Seems to be fixed now in Ionic 4.0.0-beta.15. I am closing this. "}}
{"actor":{"display_login":"bkarv"}}