Skip to content

Conversation

edygar
Copy link
Contributor

@edygar edygar commented Sep 18, 2016

Exposes withDenormalize which provides a denormalization function into a consumer selector, bound to the current store state, through a thunk. This way it can turn a localResourceID into a denormalized resource. It's useful so another reducer can refer only by localResourceIDs and denormalize it in render time.

// simple selector
connect(withDenormalize(
  state => denormalize => denormalize(state.myReducer.localID)
))(MyComponent);

// with createSelector
connect(withDenormalize(
  createSelector(
    state => state.myReducer,
    myReducer => denormalize => denormalize(myReducer.localID)
  )
))(MyComponent);

Plus, now consumers can access the resource local id by using the id symbol.

import { id } from 'redux-wpapi/symbols';

resource[id]; // contains local id of the resource.

@edygar edygar changed the title Expose a denormalization [WIP] Expose a denormalization Sep 18, 2016
@edygar edygar changed the title [WIP] Expose a denormalization Expose a denormalization Sep 19, 2016
@edygar edygar changed the title Expose a denormalization Expose a denormalization for selectors Sep 19, 2016
CHANGELOG.md Outdated

## [new release]

* Expose a denormalization mechanism so consumer can transform local ids into resources denormalized
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the PR reference and link

@xipasduarte xipasduarte merged commit 32b47ad into master Sep 19, 2016
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.

4 participants