f / vue-wait Goto Github PK
View Code? Open in Web Editor NEWComplex Loader and Progress Management for Vue/Vuex and Nuxt Applications
License: MIT License
Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
License: MIT License
Hi,
Would this be possible to add support for different name for "waitingActions".
This could be useful especially when two actions has the same name in different modules.
Something like in the example code below.
...mapWaitingActions('vuex_module_name', {
someActionFromModule: { waiter: 'this is waiter for someAction', action: 'actionName' }
}),
Kind regards,
Maciek
I can't use waitfor
helper for any situation.
Here is how I install the VueWait instance.
I think i need a waitFor
method from wait instance, but it had nothing.
import VueWait from 'vue-wait';
...
new Vue({
....
wait: new VueWait({ useVuex: true })
})
how can use the vuex-loading in mpvue
mpvue: https://github.com/Meituan-Dianping/mpvue
Documentation for vuex integration looks incomplete. Please show how to access vuex getters inside other getters. Like
[Getters.cartOperationsInProgress]: (state: CartState, getters, rootState, rootGetters): boolean => {
console.log('cartOperationsInProgress');
return rootGetters['wait/is']('cart.*');
},
For example have 2 actions: addProductToCart
, refreshCart
. Each of they call startLoading(dispatcher, 'cart')
on method enter and endLoading(dispatcher, 'cart')
before each return. The problem occurs when addProductToCart
calls refreshCart
inside. End loading occurs too early.
It is similar to nested transactions.
Looks like the most recent change increased the dist file size by nearly 7x. Was this a mistake or was that really necessary to fix the mobile Safari issue?
I would like to write a unit test with the async action such as:
File navigation.spec.js:
`
import Vue from 'vue'
import Vuex from 'vuex'
import Vuetify from 'vuetify'
import vueLoading from 'vuex-loading'
import { shallow, createLocalVue } from '@vue/test-utils'
import Navigation from '@/components/Navigation'
import { stat } from 'fs';Vue.use(Vuetify)
Vue.use(vueLoading)const localVue = createLocalVue()
localVue.use(Vuex)describe('Navigation', () => {
let store
let actions
let statebeforeEach(() => {
state = {
items: []
}actions = { getAsync: jest.fn() } store = new Vuex.Store({ state, actions })
})
it('dispatches an getAsync action', () => {
`
const wrapper = shallow(Navigation, {
store,
localVue
})
wrapper.find('button').trigger('click')
expect(actions.getAsync).toHaveBeenCalled()
})
})File Navigation.vue:
``Loading... Call ajax<script> import { mapState, mapActions } from 'vuex' export default { name: 'RecipeNavigation', computed: { ...mapState(['items']) }, methods: { ...mapActions(['getAsync']), fetchResults () { this.getAsync() }, onClose () { this.$emit('close', this.$el) } } } </script>call ajax...
- {{ item.title }}
{{ item.body }}The result of test:
[Vue warn]: Error in config.errorHandler: "TypeError: Cannot read property 'isLoading' of undefined"Please help me to pass this issue. Thank you for any help you can offer
Add option to overlay the component instead of hiding it
It should be a good feature an option to "waiting" slot overlay the content instead of hiding it since the "waiting" be able to know the component height.
Or any idea how to do this?
TypeError: this.$loading.init is not a function
Here's my question:
TypeError: this.$loading.init is not a functionuse:
"vue": "^2.5.9",
"vuex": "^3.0.1",
"vuex-loading": "^0.2.6""waiter.match is not a function"
I have the following in a JSX render function:
loading={this.$wait.isWaiting( [ "myFirstLoader", "mySecondLoader" ] )}And I recieve the error:
"TypeError: waiter.match is not a function" from utils.jsThis only happens when passing an array to isWaiting.
Support array in isLoading getter
Hi,
I think it might be a good idea having isLoading handle strings and arrays:
$loading.isLoading(['getData', 'saveData'])
Problem after build nuxt
Add transition to "waiting" slot
Hi!
I'm triying to add transitions to "waiting" slot, but it doesn't work.
Here an example codesandbox: https://codesandbox.io/s/0p2v1jmm8l
FR: Usage with namespaced Vuex modules
Splitting a Vuex store in one of my projects into namespaced modules made me think of the following.
Current way to use vue-wait with namespaced Vuex modules seems to be:
(Not documented btw.)import { mapWaitingActions } from 'vue-wait' // ... methods: { ...mapWaitingActions('users', { 'user/getUser': 'loading the user', }), }, mounted() { // get the user data this.user = this['user/getUser'](this.userId); }, // ...I think something like this would be more preferable:
import { mapWaitingActions } from 'vue-wait' // ... methods: { ...mapWaitingActions('users', { getUser: ['user/getUser', 'loading the user'], }), }, mounted() { // get the user data this.user = this.getUser(this.userId); }, // ...Thanks.
[vuex] duplicate getter key: loading/isLoading
I'm trying add this plugin to non-SPA lagacy project. And there is an error with
useVuex: true
and multipleVue
instances on same page.Looks like plugin tryes add getters for each instance and we got error from Vuex about getters already reistered
Storybook integration
Maybe we can create a static @storybook/vue for
gh-pages
branch.[Vue warn]: You are using the runtime-only build of Vue
Hello,
I use .vue files for my components and webpack.
I tried to use v-loading component on my template, and i get this error at runtime:vue.runtime.esm.js:570 [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available.
Any ideas?
thanks
Add integration with nuxt loading and axios
- Would be allow trigger NuxtJS loading api on some loaders (provide regex pattern/filter callback)
- Integrations with axios like in https://github.com/tahq69/vue-loading (maybe using loading percents calculation)
Migrating from vuex-loading
Are there some basic instructions or maybe an issue (that I wasn't able to find) about dropping vuex-loading and moving to vue-wait?
For example,
createActionHelpers
is not there anymore, what do we replace that with?
Thanks!Accessibility
Use
aria-busy
for the loading elements.Error in beforeCreate hook: "TypeError: Cannot read property 'runtime' of undefined"
Strange minification issue on Safari iphone
Hi,
There are some minification issues on Safari iphone because package.json points to dist/vue-wait.js instead of src/vue-wait.js.
"main": "dist/vue-wait.js",
Happens only on old Safari versions, below version 11.Thanks.
Allow for arrays in <v-wait> 'for' parameter
how can I remove the out wrap div and span?
wait.is of arrays fails when there's an * (for matcher) in one of the strings
i've tryed to link a loader to
$wait.is(['routing', 'fetch detail*', 'set status', 'fetch dashboard*'])
but all the fetch details (es. 'fetch detail documents' or 'fetch detail user') and all the dashboards fails to show the loader
Vue Wait with Typescript
I think that in Readme should be present a section for using this plugin in typescript.
To add the property "wait" tonew Vue({wait: new VueWait()})
you need to define a type definitions like the one attached, otherwise will be raised an error because the property does not exist.
vue-wait-property.d.ts.zipAdd typescript declaration file
Big update of the whole project to be progress management for Vue
I want to add full set of features for tracking progress information (with backward compatibility) just by extending methods with optional parameters about progress.
Because this feature will transform this library from
Complex Loader Management for Vue/Vuex Applications
toComplex Progress Management for Vue/Vuex Applications
, propose to rename this project toVue-progress
and change description to
Complex Progress Management for Vue/Vuex Applications
then we can renamethis.$loading
tothis.$progress
which is much better in my opinion.This repo then will redirect to new repo.
This is not necessary but will reflect much better the project purpose
Typo: vuex-example
Hello!
In examples/vuex-example/main.vue there is...mapWaitingActions({ incrementAsync: 'incrementing count', }),
, where string is"incrementing count"
, but in usage above there is<v-wait for="incrementing" message='incrementing...'>
, where "for" is equal to"incrementing"
. I think it should be equal to"incrementing count"
. Could you please fix this?mapWaitingActions: ability to provide actions as array
What about to map waiters with action`s names?
...mapWaitingActions('someModule', ['someAction1', 'someAction2'])
;It could be useful in some cases
Consider v-show instead of v-if for v-wait component
I noticed while I was uisng the
v-wait
component, my component that I was wrapping was being created twice. First on initial load, then again after my call to my API to load the data. Looking over the source and the vuejs docs I saw this:https://vuejs.org/v2/guide/conditional.html#v-if-vs-v-show
Which states that:
"...child components inside the conditional block are properly destroyed and re-created during toggles"
I wonder if it would be better for
v-wait
to usev-show
instead? Or add an option?What is dispatch?
In the Global Action Helpers example, a
dispatch
object is expected to be passed into thestartLoading()
method. What is this object and how do I find it? Thanks.this.$vuexLoading.isLoading error Cannot read property 'isLoading' of undefined
version: 0.2.6
I've setup vuex-loading as described in the docs, with vuex support enabled. When i use this.$vuexLoading.isLoading from a component, i get
TypeError: Cannot read property 'isLoading' of undefined
thanks in advance
add delay option
Sometimes the response is too fast (e.g. cache) so delay is good solution to avoid loading spinner if that's shows only for few milliseconds.
Here is my util fot that:
import { createActionHelpers } from 'vuex-loading' import { delay } from 'lodash/function' export function createDelayedLoading (options, wait = 1) { let actionHelpers = createActionHelpers(options) let { startLoading: startLoadingFn, endLoading: endLoadingFn } = actionHelpers if (wait) { let delayed = null actionHelpers = { startLoading: (dispatcher, loader, callback) => { delayed = delay(() => { startLoadingFn(dispatcher, loader, callback) }, wait) }, endLoading: (dispatcher, loader) => { clearTimeout(delayed) endLoadingFn(dispatcher, loader) } } } return actionHelpers }What do you think about adding something similar to the project?
make vuex optional
Hi there, your loader is best of this https://github.com/vuejs/awesome-vue#loader by api and features but require
vuex
. Can you makevuex
optional for people who use it, and provide all features by plugin itself withoutvuex
store?
I can help with that if you want.vue-element $loading scope name collision issue
Goal: Combine vue-element with vuex-loading (without vuex)
Issue: The $loading property is already added to the instance by vue-elementI tried to add the configurable option
loadingName
, but i.e.options.parent["loader"]
stays undefined.How to solve that?
// vuex-loading.js Vue.mixin({ /** * VueLoading init hook, injected into each instances init hooks list. */ beforeCreate () { const options = this.$options if (options.VueLoading) { this[options.loadingName] = typeof options.VueLoading === 'function' ? new options.VueLoading() : options.VueLoading this[options.loadingName].init(Vue, options.store) // store injection } else if (options.parent && options.parent[options.loadingName]) { console.log(this[options.loadingName]) this[options.loadingName] = options.parent[options.loadingName] this[options.loadingName].init(Vue, options.parent.$store) } } })
Add decorators
For now we need add to much mess code for using loading. Initiate start loading before action calling and call stop loading before each return or inside
finally
block. Is it possible enhance library with decorators? To add only one decorator above action.Unknown custom element: <v-wait> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Error:
Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
app.js:
document.addEventListener('DOMContentLoaded', (event) => { if (document.getElementById('app')) { new Vue({ el: '#app', store, wait: new VueWait(), components: { // ... } }) } })It does not help:
wait: new VueWait({ accessorName: '$wait', useVuex: true, vuexModuleName: 'wait', registerComponent: true, componentName: 'v-wait', registerDirective: true, directiveName: 'v-wait', })component.vue:
<template> <v-wait for="loading items"> <template slot="waiting"> <div> Loading the list... </div> </template> <ul> <li v-for="(item, index) in items" :key="index"> {{item}} </li> </ul> </v-wait> </template>Why does this error occur?
wrapLoading undefined in v0.4.0
Trying to run
import { wrapLoading } from "vuex-loading" console.log( wrapLoading ); // undefinedGuessing this is because the dist file hasn't been updated for v0.4.0?
Proposal: extend createActionHelpers api
Hi, I have a proposal: add 2 action helpers -
mapActions
andmapDecoratedActions
https://gist.github.com/fxmaxvl/9353355f352561376812e90cff6a8a8b
mapActions:
It just extends action's context and provides$loading
property withstartLoading
andendLoading
helpers.
It makes module's actions code cleaner and more testable.mapDecoratedActions:
It wraps action in try/finally block.
It can significantly reduce a boilerplate code withstartLoading
/endLoading
.Renaming the repo
Since
vuex-loading
is not really Vuex related now, we need a new name.vue-loading
is registered.Maybe we can find a fancier (hipster) name. Should we use
vue-
prefix?Transition breaking changes
Hey!
First of all, I wanna thank you for such a good job you're doing!
The problem I wanna draw your attention to is about transition. After you introduced the transition element our application got broken. So here's the thing, if we send multiple elements as content for
v-wait
, Vue is complaining about multiple elements inside oftransition
and asking to usetransition-group
instead.We can easily fix it by wrapping content into
div
, but as long as it's something that pretty hard to debug, you might want to do it onvue-wait
sideThanks!
It does not work Internet Explorer 11
This loader realy amazing and I'm happy to see made by a turkish people something open source.
when I use $wait.is('login'), error throw and everything stop working. Could you fix that, thanks.
[Vue warn]: Error in render: "TypeError: Object doesn't support property or method 'includes'"
alternative for startLoading in Vuex actions?
I was using previous
startLoading
decorator function and I don't understand how it can be replaced from the new documentation. Can you maybe point me to the right direction?Here is my example usage with vuex-loading:
dispatch('setActivities', await startLoading(dispatch, 'fetch activities', () => Activity.fetchAll()))this.$wait.end not work with v-wait.click.start
I using
vue-wait
of Nuxt.js, but itv-wait.click.start="'myloading'"
not end inthis.$wait.end('myloading')
.dependency matcher causing UglifyJS Error
Using webpack3,
a package you use "matcher" cause: (I thought it was vue-wait but seems not)ERROR in ... from UglifyJs Unexpected character '`' ...
Not sure why it is like this, I had to put your package source as well as matcher in my source and transform with my babel setup.
I was using this starting vuex-loading and it happens when I recently upgrade to this.
I think it is because matcher does not transform the code but I am not sure...
You might want to try it out yourself cuz this can make lots of frontend people move away from vue-wait which is a awesome package.There are two v1.4.6 version in the release page, and the last v1.4.6 is not published to npm
Just as the title said, the v1.4.6 in npm registry is still the old version, and lack of nuxt typescript support.
Release a new patch version could solve this, I thought.
Typo in README
The comment
//It's optional, 'loading'by default.
is (as far as I can see) wrong, default vuex module iswait
.new Vue({ el: '#app', store, wait: new VueWait({ useVuex: true, // You must pass this option `true` to use Vuex vuexModuleName: 'vuex-example-module' // It's optional, `loading` by default. }), });
Different or customizable $loading property
I find this library extremely useful, but the used property name is causing problems for me.
For example I'm using it along with element-ui, which also defined a this.$loading field resulting in errors.
In VueJS documentation, there is the recommendation of giving such field unique names:
https://vuejs.org/v2/style-guide/#Private-property-names-essentialIt would be great if the exposed field could be defined in the constructor options, or renamed entirely to something else like $vuexLoading
vuex-loading is undefined
The new version 0.2.5 seems to be broken.
import VueLoading from 'vuex-loading' console.log(VueLoading) // output undefinedRecommend Projects
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
TensorFlow
An Open Source Machine Learning Framework for Everyone
Django
The Web framework for perfectionists with deadlines.
Laravel
A PHP framework for web artisans
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
Recommend Topics
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
web
Some thing interesting about web. New door for the world.
server
A server is a program made to process requests and deliver data to clients.
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Visualization
Some thing interesting about visualization, use data art
Game
Some thing interesting about game, make everyone happy.
Recommend Org
We are working to build community through open source technology. NB: members must have two-factor auth.
Microsoft
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba
Alibaba Open Source for everyone
D3
Data-Driven Documents codes.
Tencent
China tencent open source team.