Git Product home page Git Product logo

vue-wait's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-wait's Issues

Introduce ability to declare action by name from vuex module in mapWaitingActions when two actions in different modules has the same name

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

WaitFor is broken

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 })
})

Documentation: describe vuex getters

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.*');
    },

Add support of wildcards

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.

Package size exploded

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?

How to use unit test with vuex-loading

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 state

beforeEach(() => {
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
call ajax...
  • {{ item.title }}
    {{ item.body }}
<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>
`

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

"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.js

This only happens when passing an array to isWaiting.

Problem after build nuxt

I have problem Cannot assign to read only property 'message' of object '' after build nuxt. please fix it. thanks
Screenshot 2019-03-27 at 10 59 19 AM

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 multiple Vue instances on same page.

Looks like plugin tryes add getters for each instance and we got error from Vuex about getters already reistered

[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

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!

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

Right now, the v-wait component doesn't support passing Array of strings. The component works correctly with arrays under the hood ($waitInstance.is() accepts arrays as well), but it throws the prop validation error in the console.
Screenshot 2019-07-24 at 08 38 06

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" to new 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.zip

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
to Complex Progress Management for Vue/Vuex Applications , propose to rename this project to Vue-progress and change description to
Complex Progress Management for Vue/Vuex Applications
then we can rename this.$loading to this.$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?

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 use v-show instead? Or add an option?

What is dispatch?

In the Global Action Helpers example, a dispatch object is expected to be passed into the startLoading() method. What is this object and how do I find it? Thanks.

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?

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-element

I 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 ); // undefined

Guessing 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 and mapDecoratedActions

https://gist.github.com/fxmaxvl/9353355f352561376812e90cff6a8a8b

mapActions:
It just extends action's context and provides $loading property with startLoading and endLoading 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 with startLoading / 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 of transition and asking to use transition-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 on vue-wait side

Thanks!

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()))

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.

Typo in README

The comment //It's optional, 'loading'by default. is (as far as I can see) wrong, default vuex module is wait.

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-essential

It 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 undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.