vue-async-computed icon indicating copy to clipboard operation
vue-async-computed copied to clipboard

$asyncComputed state

Open dmitriykorobkov opened this issue 5 years ago • 5 comments

$requestState.state is always updating if computed resolves to 0. It is never becomes success.

dmitriykorobkov avatar Apr 09 '19 13:04 dmitriykorobkov

Hey, I've added a test case that tries to test this issue, but I'm not managing to reproduce it. Can you take a look, and help me track down what's causing your issue?

foxbenjaminfox avatar Apr 09 '19 16:04 foxbenjaminfox

Hm. I can add I'm using default: null option too. And my async function resolves for about 1 second. Maybe, it helps to reproduce the error.

dmitriykorobkov avatar Apr 10 '19 07:04 dmitriykorobkov

Neither of those should matter (especially since the default default is already null.) I've run a variant of the test with a 1-second long timeout and an explicit default: null, but I still can't reproduce this.

Can you give me a code excerpt that seems to trigger this behaviour for you?

foxbenjaminfox avatar Apr 10 '19 09:04 foxbenjaminfox

computed: {
  isLoading() {
    return this.$asyncComputed.someOperation.updating;
  }
}
...
asyncComputed: {
   someOperation: {
     default: null,
     get() {
       return asyncFnReturnsZero();
     }
   }
}

If the asyncFnReturnsZero resolves in a non-zero value everything goes ok, but if in zero, isLoading is always true;

dmitriykorobkov avatar Apr 11 '19 06:04 dmitriykorobkov

I see what you're saying, and I've tried to replicate exactly that in the test suite here: https://github.com/foxbenjaminfox/vue-async-computed/blob/3be0d8590bf772bf05c86845347e63318438f9ab/test/index.js#L1017-L1050

The test still passes just fine, so I doubt that the problem is in something the test covers here. Is it possible that something else is going on here? Perhaps a reactivity issue of some sort in your code? (Along the lines of #18?)

If you can make an example (e.g. in codepen.io) that shows this issue happening, I'll look into it further.

foxbenjaminfox avatar Apr 11 '19 10:04 foxbenjaminfox