
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
async-source
Advanced tools
With AsyncSource you can
In case of multiple calls - only last call will be processed. Connect AsyncSource to your dynamic selects with in build debounce
npm install --save async-source
// javascript
import AsyncSource from 'async-source';
const source = new AsyncSource(request);
async function loadItems() {
await source.update(...requestParams);
const response = source.data;
}
// typescript
import AsyncSource from 'async-source';
const source = new AsyncSource<RespnonsType>(request);
async function loadItems() {
await source.update(...requestParams);
const response = source.data;
}
Parameter | Is required | Description |
---|---|---|
serviceMethod | true | Method that returns promise |
errorHandler | false | Function that will be called in case of service method rejected |
delay | false | delay in ms |
Property | Description | Type |
---|---|---|
data | Returns your method response | Your method response |
isLoading | Returns true when request pending | Boolean |
isFetch | Returns true after first load | Boolean |
Method | Description | Params |
---|---|---|
update | Calls be request | Your method request params |
push | Calls be request and handles success response | Success handler, Your method request params |
updateIfEmpty | Calls be request in source data is empty | Your method request params |
clear | Set source data to initial state(null) | --- |
<template>
<ul v-loading="isLoading">
<li v-for="item in items" :key="item.id">
{{ item.name }}
</li>
</ul>
</template>
<script>
import AsyncSource from 'async-source';
import { computed, reactive } from 'vue';
export default {
name: 'MyComponent',
setup() {
function errorHandler(error) {
console.error(error);
}
const source = reactive(new AsyncSource(request, errorHandler, 300));
source.update();
const items = computed(() => source.data || []);
const isLoading = computed(() => source.isLoading);
return {
items,
isLoading
};
}
}
</script>
<template>
<ul v-loading="isLoading">
<li v-for="item in items" :key="item.id">
{{ item.name }}
</li>
</ul>
</template>
<script>
import AsyncSource from 'async-source';
export default {
name: 'MyComponent',
data() {
return {
source: new AsyncSource(request, this.errorHandler, 300)
}
},
computed: {
items() {
return this.source.data || [];
},
isLoading() {
return this.source.isLoading;
}
},
created() {
this.source.update();
},
methods: {
errorHandler(error) {
console.error(error);
}
}
}
</script>
FAQs
async requests wrapper
We found that async-source demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.