Skip to content
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

Add getter() function + Normalised Store example #58

Merged
merged 5 commits into from
Oct 31, 2017

Conversation

quandhz
Copy link
Owner

@quandhz quandhz commented Oct 27, 2017

Branch: https://github.com/quandhz/resaga/tree/subscribe_value_getter
Resolve: #57

Run example npm run examples:normalise

getter(value, initialProps) => filteredValue;

Now we can subscribe to a value with your own getter function to filter out what we don't need.

Pseudo-code

// BookItem component
const CONFIG = {
  value: {
    title: {
      keyPath: ['BookPage', 'books'],
      getter: (books, initialProps) => books[initialProps.id].title,
    },
  },
};

Usage

<BookItem id={1} />
<BookItem id={2} />
<BookItem id={3} />

Each BookItem will subscribe to its book title based on the id passed in.

@quandhz quandhz merged commit ea79c9d into master Oct 31, 2017
@quandhz quandhz deleted the subscribe_value_getter branch October 31, 2017 02:01
@codecov
Copy link

codecov bot commented Oct 31, 2017

Codecov Report

Merging #58 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #58   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          27     30    +3     
  Lines         329    370   +41     
  Branches       68     85   +17     
=====================================
+ Hits          329    370   +41
Impacted Files Coverage Δ
lib/internal/helpers/selectors.js 100% <100%> (ø)
...ib/internal/hoc/components/helpers/exportValues.js 100% <100%> (ø)
lib/internal/helpers/analyseConfig.js 100% <100%> (ø) ⬆️
lib/internal/hoc/components/SimpleResaga.js 100% <100%> (ø) ⬆️
lib/internal/hoc/withResaga.js 100% <100%> (ø) ⬆️
lib/internal/helpers/subscribeValue.js 100% <100%> (ø)
lib/internal/selectors.js 100% <100%> (ø) ⬆️
lib/internal/hoc/withSimplifyResaga.js 100% <100%> (ø) ⬆️
lib/internal/hoc/components/Resaga.js 100% <100%> (ø) ⬆️
... and 2 more

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 b74238a...c638879. Read the comment docs.

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.

1 participant