[Bug] MakeFindMixin: local option doesn't works as specified in the docs
See original GitHub issueSteps to reproduce
In a template, add a makeFindMixin like this:
mixins:[ makeFindMixin({ service: "yourServiceName", local: true, params: () => ({}) }) ]
Expected behavior
The mixin should not make a request to the API server but use the params to pull data from the local store as stated in the docs.
local {Boolean|String|Function} - when true, will only use the params prop to pull data from the local Vuex store. It will disable queries to the API server. The value of local will override queryWhen. Default:false
Actual behavior
The API request is sent, the local option is not respected. If you omit the params option, the API request is not sent but the store getter returns nothing.
What cause this behavior
In the created lifeCycle event, on this line , only the presence of the params and fetchParams options are checked in order to make the API request.
If they are not present, the absence of the local option is used to log a message.
How to fix it
Check the truthiness of the local option to send the API request or not. I can submit a PR if everything is ok.
System configuration
Module versions: 3.2.1
NodeJS version: 12.4.0
Operating System: Linux
Browser Version: Chromium 79
Module Loader: Webpack
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
That is a very good point. Nice job looking even further ahead. That will be a great optimization.
OK but why in the watcher? We could put it simply at the beginning of the created event, no? What would be the difference?
Correct me if I’m wrong but isn’t the purpose of the created event to only make the find request when it is triggered and when the params change?
In that case, we could even add the created property conditionally, it would make the mixin lighter.