question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is not sent (pristine) indicator/flag/state

See original GitHub issue

Hello. Thank you for your library, it’s great!

In some cases, we need to know that the request hasn’t been sent yet at all. But getQuery always returns the default structure:

https://github.com/klis87/redux-saga-requests/blob/master/packages/redux-saga-requests/src/selectors/get-query.js#L121

const defaultQuery = {
  data: null,
  loading: false,
  error: null,
};

Just checking over data is null won’t work as the backend may return, for example, either null or a model (yes, that happens ¯_(ツ)_/¯).


Is there a way to extend defaultQuery (not default data) or to understand, that the query is “pristine”?

It looks like, just adding pristine flag to defaultQuery should solve the issue as the default query is returned any time when there is no data for the query (it’s not initialized/sent/etc.) in requests` state.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
klis87commented, Apr 3, 2020

@cluk3 In reducers there is even no loading prop, there is just pending counter, which is just integer, number of current pending requests of a given type. Boolean would be indeed buggy, as for instance sequence 1stREQUEST > 2ndREQUEST > 1stRESPONSE > 2ndRESPONSE would cause 1stRESPONSE to set loading to false despite the fact there is still 2ndREQUEST pending.

getQuery transforms pending integer as loading: pending > 0

This task is to give 1 extra information, to distinguish between:

  1. I dont have any pending requests of a given type, and I did not even fire any request yet
  2. I already fired request of this type, but response.data from server was null and I really want to know that I tried, but data was empty

This flag wont be necessary for response.data like empty, or [], but for null it is as by default data is null if nothing was fetched or a query was reset.

Regarding the attached article, I agree that booleans can be abused if you have many states, and state machines are better then, but in our case 90% people will need only loading flag, pristine will be just extra flag for 10% cases. I dont want all people to do if(query.loading === 'loading', just if(query.loading)

1reaction
ghostcommented, Mar 31, 2020

Hello! Thank you for your reply.

For now, it’s resolved at the request level. An Axios interceptor runs a casting function if it’s passed in the config. It just throws a simulated not found error.

The issue is not for a particular problem. It’s very handy in many cases to have an ability to understand that the request is “pristine”. I’m glad to know there is the roadmap with the feature coming!

Looking forward to new versions. This issue can be closed. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

ROADMAP · Issue #306 · klis87/redux-requests
getRequestKey renamed to requestKey , u just pass value not callback anymore, ... Is not sent (pristine) indicator/flag/state #329.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found