-
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
Simplify app code needed to load and access resource (and entities). #17
Labels
enhancement
New feature or request
Comments
orther
added a commit
that referenced
this issue
Apr 25, 2018
This newest version adds ability to track an actions status with action and id which makes tracking multiple requests to the same endpoint concurrently possible. The selectors have also been renamed. To support selector generation in the new helpers outlined in #17 we need to expose these.
orther
added a commit
that referenced
this issue
Apr 26, 2018
* libs: Update redux-saga-thunk v0.7.1 This newest version adds ability to track an actions status with action and id which makes tracking multiple requests to the same endpoint concurrently possible. The selectors have also been renamed. To support selector generation in the new helpers outlined in #17 we need to expose these. * refactor: Update resource success action payload #16 * refactor: Update resource sagas to provide new success payload format * docs: Added Usage docks for resource action promise interface #16 * fix(resource): Delete Success saga call and action bug * feat: Add createResourceHelper w/ only resouceCreate implemented Need to write tests and implement the rest of these helper functions. * feat(resource): WIP Add createResource w/ action test Still need to add selectors tests and implement other resource request types. * tests(helpers): WIP Add test for resourceCreate data selectors * feat(helpers): Complete createResourceHelper
🎉 This issue has been resolved in version 0.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
There is quite a bit of boilerplate and ceremony involved to loading a resource,
checking it's status (pending/failed/done/etc) and then getting the response
using selectors (and pulling from entities if an entityType was set).
Traditionally using the redux-saga-thunk pattern is how we've avoided using
selectors. We can make this lib easier to use (less code, less thinking) and
more robust by providing mechanism(s) that do what the current boilerplate code
does. To support multiple use cases I believe it makes sense to provide these
helpers as action/selectors creators, render prop components (based off
selectors) and possible HoCs (higher order components).
Current Usage Example
Here is an example from one of our projects using resource/entities
redux-modules (not from uptrend-redux-modules but it has same API). Notice how
the request path
member/search
is used in the status selectors and in resourcegetList selector. Also the entity type
memberSearch
is used in request actionand entities getList selector. Do note request path and entityType always need
to match like this:
Desired Usage Example
What the search object looks like:
Action & Selectors Creator
It should be pretty straight forward to create a helper that returns the request
action and selectors for accessing a resource like the above example.
src/store/helpers/index.js
src/containers/MemberAddContainer.js
Render Prop Components
TBD - (Mostly copied from AECS)
Implementation Checklist
Upgrade redux-saga-thunk
Helper Creators (one for each action creator below)
resourceCreateRequest = (resource, data, entityType) => ({
resourceListCreateRequest = (resource, data, entityType) => ({
resourceUpdateRequest = (resource, needle, data, entityType) => ({
resourceListReadRequest = (resource, params, entityType) => ({
resourceDeleteRequest = (resource, needle, entityType) => ({
resourceDetailReadRequest = (resource, needle, entityType) => ({
resourceDeleteRequest = (resource, needle, entityType) => ({
The text was updated successfully, but these errors were encountered: