Skip to content

feat(table): Split computedItems into multiple functions #1893

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
Jun 16, 2018

Conversation

gaaf
Copy link
Contributor

@gaaf gaaf commented Jun 15, 2018

To make it easier to extend the functionality of b-table without feature creep in the b-table itself, a bit more/easier access to the various stages of computedItems is needed.

For example, to implement #225 externally, access is needed to the filtered and sorted, but not yet paginated items. With this change this becomes possible by doing something like this:
const table = this.$refs.the-table
let items = table.hasProvider ? table.localItems : table.items
items = table.sortItems(table.filterItems(items))

This PR incorporates no functional changes and adds no features.

Don't do all the processing in one function so external users (parent) can
grab the items at various stages without having to reproduce all the
filtering/sorting/pagination logic.

For example a parent may want to have access to the filtered and sorted,
but not yet paginated set of items. With the split functions it can now
do something like this:
    const table = this.$refs.the-table
    let items = table.hasProvider ? table.localItems : table.items
    items = table.sortItems(table.filterItems(items))

This patch incorporates no functional changes.
@gaaf gaaf force-pushed the split-computed-items branch from e0d6a5f to 05c0915 Compare June 15, 2018 15:00
@codecov
Copy link

codecov bot commented Jun 15, 2018

Codecov Report

Merging #1893 into dev will increase coverage by 0.02%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff            @@
##             dev    #1893      +/-   ##
=========================================
+ Coverage   61.2%   61.23%   +0.02%     
=========================================
  Files        154      154              
  Lines       2882     2884       +2     
  Branches     797      796       -1     
=========================================
+ Hits        1764     1766       +2     
  Misses       802      802              
  Partials     316      316
Impacted Files Coverage Δ
src/components/table/table.js 76.38% <92.85%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2970509...2465b14. Read the comment docs.

Refactor `filterItems` method
@tmorehouse
Copy link
Member

This change actually broke efficient reactivity, since the computed prop getters were moved from a computed prop into non reactive methods.. slowing down rendering on larger tables.

External functions/addons should not be dipping into unpublished methods or computed props. Event interfaces or oneway-syncable props should be used instead.

PR #2149 fixes the broken reactivity by making sure the props/data that need to be reacted on are inside computed props (i.e to register that they are dependent upon them. Moving to methods broke that).

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

Successfully merging this pull request may close these issues.

3 participants