Skip to content

Using ListViews is hard #66

@tjvantoll

Description

@tjvantoll

I built Groceries as an ng2 web app (see https://github.com/tjvantoll/Groceries), and I’m trying to port as much of that code as possible to the Groceries {N} app.

One thing that struck me is just how much harder it is to build a list in {N}. For Groceries web I was able to trivially bind a <ul> to an array of objects. In {N} trying to accomplish the same task is considerably harder. Here’s a short list of things I’ve found that I have to do. (The full code is in this .html file and this .ts file.)

  1. Use <item-template> and <template> instead of ngFor. I realize this is due to the difference in how our ListView works, but I thought it was still work explicitly mentioning.
  2. Use the async pipe in my template.
  3. Set the component’s changeDetection to ChangeDetectionStrategy.OnPush.
  4. Bind to an rxjs/Observable instead of just a simple array.
  5. Wrap the array in a WrappedValue so that {N} recognizes pushes to the array.

Really all I want to do is bind the <ListView> to a simple array like I can do in ng2 web apps, so if at all possible I’d love to see 2–5 above go away. <ListView>s are really common and I don’t think I’ll be the first person to be confused by these requirements. Removing them would also allow for more code reuse between {N} and web apps.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions