
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@liqueflies/vuex-async-module
Advanced tools
Reduce async boilerplate code generating Vuex modules. Compatible with Vue 2.x
npm install @liqueflies/vuex-async-module --save
# or
yarn add @liqueflies/vuex-async-module
vuex-async-module
generates Vuex Modules reducing boilerplate for asynchronous request, inspired by this post of Lachlan Miller.
The workflow for a successful asynchronous request should be like:
state = {
isPending: true // pending... show a spinner
statusCode: null,
data: null,
errors: null
}
// some time later... the ajax request is successful
state = {
isPending: false, // no longer pending
statusCode: 200, // success code 200
data: {...}, // response data
errors: null // no errors
}
Standard Vuex code should write also types
, actions
, mutations
, and getters
for each async action.
We can notice that in many cases we will write the same code over and over again.
vuex-async-module
will scaffold this code for you.
import getAsyncModule from '@liqueflies/vuex-async-module'
export default new Vuex.Store({
state, // your state,
actions, // your actions
getters, // your getters
mutations, // your mutations
modules: {
// use a promise async library that return data and status on response
movies: getAsyncModule({ xhr: axios.get })
}
})
and then in your .vue
import { asyncModuleMixin } from '@liqueflies/vuex-async-module'
export default {
// component `name` is the same as module name
name: 'movies',
// include mixin for automatically bind two computed props:
// [componentName]RequestIsPending i.e moviesRequestIsPending
// [componentName] i.e. movies
// and a method!
// getAsync[componentName] i.e. getAsyncMovies(url, forceUpdate)
mixins: [asyncModuleMixin],
// place this call where you prefer, here we will use `beforeMount`
beforeMount () {
this.getAsyncMovies({ url: 'https://ghibliapi.herokuapp.com/films' })
}
}
and in the template
<div v-if="moviesRequestIsPending" />
<ul v-else>
<li v-for="movie in movies" :key="movie.id">
<h2> {{ movie.title }} - {{ movie.release_date }} </h2>
</li>
</ul>
vuex-async-module
has only one constrain: component
name must be the same of module
name.
vuex-async-module
mixin adds two computed
properties:
componentName
]RequestIsPending - i.e moviesRequestIsPending
componentName
] - i.e. movies
and a method
componentName
] i.e. getAsyncMoviesgetAsync
expects to receive the url for the ajax call, and a boolean parameter to force the update of the previous fetched data.
And the job is done!
Thanks to Marco Solazzi and Giovanni Rodighiero.
Copyright (c) 2017 Lorenzo Girardi
FAQs
vuex async module generator.
The npm package @liqueflies/vuex-async-module receives a total of 1 weekly downloads. As such, @liqueflies/vuex-async-module popularity was classified as not popular.
We found that @liqueflies/vuex-async-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.