Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global defaults for pending and error #8

Open
posva opened this issue Mar 12, 2018 · 14 comments
Open

Global defaults for pending and error #8

posva opened this issue Mar 12, 2018 · 14 comments
Labels
enhancement New feature or request

Comments

@posva
Copy link
Owner

posva commented Mar 12, 2018

In big applications, it is very common to use similar if not the same pending and error handler. This would prevent a lot of boilerplate from users

@posva posva added the enhancement New feature or request label Mar 12, 2018
@Herteby
Copy link

Herteby commented Apr 6, 2018

👍 Yup, this would be very useful!

@Herteby

This comment has been minimized.

@posva
Copy link
Owner Author

posva commented Sep 28, 2018

It's similar, except I was thinking about hoisting the Catch and Error component with some conventions in the lib file and use them as fallbacks. Passing a prop for the component also looks like a good thing as it is possible to have different kind of errors or loading components but at the same time I feel like duplicating the API for a ver small syntax gain that is chained to a convention on the error prop

@Herteby

This comment has been minimized.

@posva

This comment has been minimized.

@Herteby

This comment has been minimized.

@posva

This comment has been minimized.

@Herteby

This comment has been minimized.

@posva

This comment has been minimized.

@Herteby

This comment has been minimized.

@Mat-thieu
Copy link

Hey man, I've used your package for a long time now (it's great) and the way I do it now is wrapping vue promised inside my own component which has a default loader (but can be changed by a prop) and a default error state.

I have some thoughts on making this easier being a package though, how about you make a plugin out of it instead of a component, that way you can pass options and do something like this:

import { Promised } from 'vue-promised';
import LoadingComponent from '';
import ErrorComponent from '';

Vue.use(Promised, {
  id: 'vue-promised', // Promised by default?
  defaults: {
    pending: LoadingComponent,
    catch: ErrorComponent,
  },
});

The plugin registers the component, the LoadingComponent and ErrorComponent both receive the slot-scope as props.

@posva
Copy link
Owner Author

posva commented Mar 8, 2019

Hello, I'm glad you like it. It won't be a plugin, I want to keep the flexibility of a component. The registration will probably be done through an exported function or by setting a property in the component option object

@Mat-thieu
Copy link

@posva Alright, well I wouldn't really know how to abstract away the complexities of that, but I'm keen to see how you'll solve it :).

Good luck, looking forward to your solution!

@CKATEPTb

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants