Why does using axios.all as multiple endpoints unify subscription names into one? #3343
-
When calling endpoint as shown below const [fetchApplicantInStepSearch] = useLazyFetchApplicantInStepSearchQuery();
const [res1, res2, res3, res4] = await Promise.all([
fetchApplicantInStepSearch(80).unwrap(),
fetchApplicantInStepSearch(81).unwrap(),
fetchApplicantInStepSearch(82).unwrap(),
fetchApplicantInStepSearch(83).unwrap(),
]); Subscribed names are as follows. // subscribe 1
{
api: {
subscriptions: {
fetchApplicantInStepSearch("80"): {},
fetchApplicantInStepSearch("81"): {},
fetchApplicantInStepSearch("82"): {},
fetchApplicantInStepSearch("83"): {
"qhSj7quEEIrSVEbPaba4S": {
"pollingInterval": 0
}
},
}
// subscribe 2
{
api: {
subscriptions: {
fetchApplicantInStepSearch("83"): {
"6Vjgrax5qyLclSG0V59iV": {
"pollingInterval": 0
}
},
}
// subscribe 3
{
api: {
subscriptions: {
fetchApplicantInStepSearch("83"): {
"72jgCi4_B-KMXn8HoknmX": {
"pollingInterval": 0
}
},
}
// subscribe 4
{
api: {
subscriptions: {
fetchApplicantInStepSearch("83"): {
"CqPhQ_EMVZ1bviq1BNKsW": {
"pollingInterval": 0
}
},
} Why do all the subscription names become the same? I want to know why and how to solve it. |
Beta Was this translation helpful? Give feedback.
Answered by
EskiMojo14
Apr 12, 2023
Replies: 1 comment 1 reply
-
useLazyQuery only subscribes to one argument at a time, so each trigger is overriding the last. const res1 = useFetchApplicantInStepSearchQuery(80);
const res2 = useFetchApplicantInStepSearchQuery(81);
const res3 = useFetchApplicantInStepSearchQuery(82);
const res4 = useFetchApplicantInStepSearchQuery(83); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dev-splin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useLazyQuery only subscribes to one argument at a time, so each trigger is overriding the last.
If you want to subscribe to multiple at the same time, call the hook itself multiple times: