Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove parent data from child scope #86

Closed
adityasharat opened this issue Apr 24, 2017 · 0 comments
Closed

Remove parent data from child scope #86

adityasharat opened this issue Apr 24, 2017 · 0 comments

Comments

@adityasharat
Copy link
Collaborator

We should not insert parent data into a child scope. This will leak the parent data into the child scope, and also breaks the layout-data interface. Removing this will also improve performance by avoiding the copying loop per scope object.

Data

{
  "user": {
    "dt": "2017 04 22",
    "ll": "01, XZY, AB"
  }
}

Layout

{
  "type": "TextView",
  "layout_width": "wrap_content",
  "layout_height": "wrap_content",
  "textSize": "14sp",
  "data": {
    "date": "@{fn:date(@{user.dt},'E, d MMM')}"
  },
  "text": "@{fn:format('last login: %s from %s',@{date},@{user.ll})}"
}

Here in the layout user.ll is not added to the data scope of the layout and is only accessible from the outer scope. user.ll should be added to the data scope instead. As follows:

{
"type": "TextView",
"layout_width": "wrap_content",
"layout_height": "wrap_content",
"textSize": "14sp",
"data": {
"date": "@{fn:date(@{user.dt},'E, d MMM')}",
"loc": "@{user.ll}"
},
"text": "@{fn:format('last login: %s from %s',@{date},@{loc})}"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant