Skip to content

Fix ObservableArray items in ListView (Fixes #464) #498

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

Merged
merged 2 commits into from
May 31, 2019

Conversation

elie-g
Copy link
Contributor

@elie-g elie-g commented May 24, 2019

Just a small patch to fix #464.

I changed the items prop's type to Object and instead added a validator function which ensures items is either an Array or an ObservableArray. I also adapted the @itemTap event emitter correspondingly.

Edit: I also added a sample for the issue

@rigor789
Copy link
Member

@DrunkenPoney Thanks for the PR!
I think we could use type: [Array, Object] in the props declaration, to allow both - but I like the validator approach too, as it's more specifically checking for Array or ObservableArray!

I'm working on the vue 2.6 version, so I will likely release this as part of that, rather than creating a patch release right away.

@elie-g
Copy link
Contributor Author

elie-g commented May 24, 2019

@rigor789 Wouldn't it be redundant to check for both types (Array and Object) since Array inherits from Object so an array is also an object?

@rigor789
Copy link
Member

@DrunkenPoney haven't even thought about that - that's a good point!

@rigor789 rigor789 changed the base branch from master to dev May 31, 2019 11:39
@rigor789 rigor789 merged commit 9ba14d5 into nativescript-vue:dev May 31, 2019
rigor789 pushed a commit that referenced this pull request May 31, 2019
…498)

* fix(listview): fix ObservableArray items in ListView (#464)

fix #464

* fix(samples): add sample for issue #464

ref #464
@tralves
Copy link

tralves commented May 31, 2019

Well, turns out we do need both. Vue makes that distinction when validating props. This is what I got now:

JS: [Vue warn]: Invalid prop: type check failed for prop "items". Expected Object, got Array 
JS: 
JS: found in
JS: 
JS: ---> <ListView>
JS:        <MessageList> at components/MessageList.vue

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

Successfully merging this pull request may close these issues.

3 participants