f / vue-wait

Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
MIT License
2k stars 101 forks source link

Add decorators #15

Open Koc opened 6 years ago

Koc commented 6 years ago

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.

f commented 6 years ago

Do you have any API proposals?

sky-code commented 6 years ago

I would like decorators too, but current state of decorators is cutting edge, so I will wait stable release of decorators in webpack (i.e. without flags)

yoyoys commented 5 years ago

WaitFor should have a decorator, it's hard to use.

before:

waitSomething = waitFor('somthing is waiting', async function() {
  ... doing
})

after:

@WaitFor('somthing is waiting')
async waitSomething () {
  ... doing
}

here is the implement

function WaitFor(waiter: string) {
  return function decorator(target, name, descriptor) {
    return waitFor(waiter, descriptor);
  };
}