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

fix(observable-array): splice to notify correct amount of added items by manoldonev · Pull Request #7452 · NativeScript/NativeScript · GitHub

fix(observable-array): splice to notify correct amount of added items - #7452

Merged
manoldonev merged 1 commit into
releasefrom
mdonev/observable-array-splice-fix
Jul 4, 2019
Merged

manoldonev merged 1 commit into
releasefrom
mdonev/observable-array-splice-fix

Conversation

Copy link
Copy Markdown
Contributor

cherry-picked from #7426

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

manoldonev self-assigned this Jul 3, 2019
cla-bot Bot added the cla: yes label Jul 3, 2019

Copy link
Copy Markdown
Contributor Author

test package_version#rc

1 similar comment

dtopuzov commented Jul 4, 2019

Copy link
Copy Markdown
Contributor

test package_version#rc

manoldonev merged commit d8ef044 into release Jul 4, 2019
manoldonev deleted the mdonev/observable-array-splice-fix branch July 4, 2019 12:45
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.

4 participants


Back | FazBrowse Home | New Git URL