npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@simpli/vue-await

v1.0.5

Published

Easy-to-use loading indicator

Downloads

43

Readme

Vue-Await

Easy-to-use loading indicator

Install

npm i @simpli/vue-await

Import

import Vue from 'vue'
import VueAwait from '@simpli/vue-await'

Vue.use(VueAwait)

On your Scss:

@import "~@simpli/vue-await/scss/await";

Basic Usage

<await name="myRequestName">
  To be shown after loading
</await>

On a Vue instance:

this.$await.run('myRequestName', async () => {
  // Make the request here
})

Outside a Vue instance:

import {$await} from '@simpli/vue-await'

$await.run('myRequestName', async () => {
  // Make the request here
})

Other props and slots

<await
  name="myRequestName"
  effect="vueTransitionCssClass"
  spinner="vueComponentNameToBeRenderedOnLoading"
  :spinnerColor="colorThatWillBePassedAsPropToTheComponent"
  :spinnerPadding="paddingForTheLoadingElement"
  :spinnerScale="zoomForTheLoadingElement"
  @loading="callbackWhenLoading"
  @error="callbackWhenErrorIsThrown"
>
  The content to be shown after loading
  <template slot="error">
    The content to be shown if a error is thrown
  </template>
</await>

Define the loading indicator with a slot

<await
  name="myRequestName"
>
  The content to be shown after loading
  <template slot="loading">
    The content to be shown when loading
  </template>
</await>

Configure the Default behaviour

$await.defaultTransition = 'vueTransitionCssClass'
$await.defaultSpinner = 'vueComponentNameToBeRenderedOnLoading'
$await.defaultSpinnerColor = '#42b983'
$await.defaultSpinnerPadding = '10px'
$await.defaultSpinnerScale = 1

$await Methods

// gets the component to be shown when 'myRequestName' is loading
const spinnerOfMyRequest = $await.loader['myRequestName']

// define the component to be shown when using 'MyComp' as loader
$await.addLoader('MyComp', MyComponentClass)

// returns a boolean indicating if 'myRequestName' is loading
const isLoading = $await.inAction('myRequestName')

// initialize the loading passing the request name
$await.init('myRequestName')

// ends the loading of 'myRequestName'
$await.done('myRequestName')

// indicate an error on 'myRequestName'
$await.error('myRequestName')

// initialize the loading, process the request on the callback and then ends the loading
$await.run('myRequestName', async () => {
  // your request goes here
})

Using with Serialized-Request

RequestListener.onRequestStart(reqName => $await.init(reqName))
RequestListener.onRequestEnd(reqName => $await.done(reqName))

Using with Vue-spinner

import ScaleLoader from 'vue-spinner/src/ScaleLoader.vue'

$await.addLoader('ScaleLoader', ScaleLoader)
$await.defaultSpinner = 'ScaleLoader'