-
Notifications
You must be signed in to change notification settings - Fork 1
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
ResourceLoader return state selector based values #31
Comments
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 My current plan is to update ResourceLoader to return raw resource response data, entities data, and then update the |
Actually it would make more sense to match the resourceHelpers selectors as described in #17 and follow this conventions:
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... |
Current thinking is added a const requestResult = {
api: payload.api,
data: payload.data,
entities: payload.entities,
entityType: payload.entityType,
resource: payload.resource,
} |
Final thoughts before stopping for the night.... By providing the {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 |
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. |
Overview
Currently the ResourceLoader component returns a
result
property in the object passed to the child render prop for accessing the resource or entities the component loaded.result
holds a value returned from the resource request action. This means any updates to the resource or entities redux state wont effect theresult
value. The problem is that in many (most?) cases after loading a resource you would actually want to render the data from the global state so your view will update if there are any state changes. For example if you load a list of resource entities to render an overview that has button to delete one. A resource delete request will update the state. A situation where you would want to use the actual resource request results is backend paginated search forms.Current Usage Example
The following is a contrived example with a
<DeleteUserButton ... />
that when clicked triggers a resource delete request for that user. The problem arrises when the delete request is successful but the user list doesn't update to not include the deleted user.Solutions
I have several ideas on how we should solve this but it isn't yet clear which solution is best. Below are a list of ways to solve the problem:
EntityList
component to render the list.EntityList
EntityList
inside theResourceListLoader
to reduce boilerplate.result
.Final Notes
I am currently considering several use cases that aren't well supported by current helpers so there is a possibility a overarching refactor will impact this use case.
The text was updated successfully, but these errors were encountered: