Comments (5)
It looks like none of this extra madness would be necessary if I just fully implemented the ResourceLoader component as detailed in #19 In the issue it's explained that if the resource was normalized by setting the entityType
prop then the results passed to child render prop is the entities rather than the resource(s) and so it would be default be based on state.
My current plan is to update ResourceLoader to return raw resource response data, entities data, and then update the result
prop to hold either response data or entities data based on whether the resource was normalized by setting a entityType
prop value.
from uptrend-redux-modules.
Actually it would make more sense to match the resourceHelpers selectors as described in #17 and follow this conventions:
// returned data
resource, // <- resource data (when normalized returns entity id(s))
result, // <- if the resource was normalized into entities this
// holds the list of entities, otherwise returns the
// resource data (non-normalized)
With that said, we should provide access to the raw API response data too for features like pagination. So we may want to add another prop that holds extraneous values. Will consider...
from uptrend-redux-modules.
Current thinking is added a requestResult
prop that has the following data from the resource request success action payload:
const requestResult = {
api: payload.api,
data: payload.data,
entities: payload.entities,
entityType: payload.entityType,
resource: payload.resource,
}
from uptrend-redux-modules.
Final thoughts before stopping for the night....
By providing the requestResult
object as outlined above I was nicely able to use EntityList component to load the entities from state. By doing so updates to state reflect in the rendered list.
{status.success &&
locationList &&
entities &&
<EntityList entityIds={entities} entityType="planAppLocation">
{locationList => {
console.log('locationList', locationList);
return (
<OrgPlanAppLocationOverviewPage
orgId={orgId}
planAppId={planAppId}
locationList={locationList}
/>
);
}}
</EntityList>}
I created a branch with EntityList and EntityDetail created inside the ResourceLoader component but I feel like that is the wrong solution. Instead a separate component should be made that simply joins the two. Branch here: https://github.com/uptrend-tech/uptrend-redux-modules/tree/resource-loader-include-entities-experimental
from uptrend-redux-modules.
Closing since we are using the EntityDetail and EntityList components to solve this for now. Still not sure what the best path forward is to remove even more boilerplate.
from uptrend-redux-modules.
Related Issues (20)
- Entity loader/reader React components HOT 2
- Documentation
- Resource params are inserted into URL under 'params' key with json-encoded string HOT 1
- Resource Helper - Add new selector to return `status` object
- ResourceLoader appending params={} HOT 1
- Remove entities from state after successful Resource Delete request HOT 1
- Add Resource Components for Create, Update, Delete HOT 5
- Warn that entities middleware needs to be before redux-saga-thunk
- In resource helper components, load new resource when `resource` prop changes HOT 3
- Add caching to Resource HOT 2
- Remove camel case for dash based keys (UUIDs) HOT 1
- After v0.10.0 release the render is blank and showing warning HOT 2
- ResourceLoader: More flexible render options and defaults
- Resource loader components should reload if request params change
- Support entity returned from DELETE request when HTTP status is 200 HOT 1
- EntityList helper component returns every entity if entityIds undefined HOT 1
- Standardize the resource loading status names between helper selectors and ResourceLoader components
- ResourceLoader components error: Invariant Violation: Could not find "store" in the context... HOT 2
- Ability to disabled automatic snake/camel-casing resource request/response data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uptrend-redux-modules.