FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(observable-array): splice(...) to return correct amount of added items by edusperoni · Pull Request #7426 · NativeScript/NativeScript · GitHub

fix(observable-array): splice(...) to return correct amount of added items - #7426

Merged
manoldonev merged 2 commits into
NativeScript:masterfrom
edusperoni:observable-array-splice
Jul 3, 2019
Merged

manoldonev merged 2 commits into
NativeScript:masterfrom
edusperoni:observable-array-splice

Conversation

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

ObservableArray splice does not notify the number of updated items and it can't be inferred from the passed arguments.

What is the new behavior?

ObservableArray splice adds all updated items to addedCount, using a logic of "x items removed, y items added in their place"

The amount of change in the length of the array can be always inferred by addedCount - removed.length.

This fixes a bug that would cause FormattedString.spans.splice to keep removing spans and never adding any back.

Fixes #7425.

BREAKING CHANGES:

The addedCount variable from ObservableArray's splice change event is always the amount of added items.

Migration steps:
Ideally, developers should handle the case where items are replaced by splice. The old addedCount can be obtained by

const addedCount = event.addedCount - event.removed.length

cla-bot Bot added the cla: yes label Jun 29, 2019

Copy link
Copy Markdown
Contributor Author

Oops, my mistake, Some weird commits went with it. Let me fix it

edusperoni force-pushed the observable-array-splice branch from 85409ef to 0e5cb42 Compare June 29, 2019 00:17
edusperoni changed the title Observable array splice fix: Observable array splice does not return the correct amount of added items Jun 30, 2019

Copy link
Copy Markdown
Contributor

test

manoldonev changed the title fix: Observable array splice does not return the correct amount of added items fix(observable-array): splice(...) to return correct amount of added items Jul 3, 2019
manoldonev merged commit 5e14de6 into NativeScript:master Jul 3, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ObservableArray does not notify correctly when splice replaces elements

2 participants


Back | FazBrowse Home | New Git URL