
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
@fabienarcellier/cached-query
Advanced tools
powerful asynchronous data fetching management for vanillajs
This library is experimental. Its API is likely to evolve between 2 versions. It covers a need immediate but I do not undertake to ensure its maintenance.
powerful asynchronous data fetching management for vanillajs.
This library is inspired from :
I wanted to use a frontend library Alpine.js, lighter than React or Vue.js, to make interactive interface.
I was looking for an equivalent of react-query to decouple data loading from a remote API as query, deduplicate REST requests if several components load the same data source, update all components when the request is invalidated, regularly pull a data source and update all the components that use it.
As I couldn't find a library for vanillajs, I implemented cached-query
npm install --save @fabienarcellier/cached-query
You can find the latest version to ...
git clone https://github.com/FabienArcellier/cached-query.git
preparedCquery("users", "https://randomuser.me/api/?seed=foobar&results=5")
function users() {
cquery("users", (data, loading, error) => {
if (loading == false) {
console.log(data.results)
}
})
}
function user_by_gender() {
cquery("users", (data, loading, error) => {
if (loading == false) {
results = {}
for (key in data.results) {
user = data.results[key]
gender = user.gender
if (!(gender in results)) {
results[gender] = []
}
results[gender].push(user)
}
// display the list in the dom element
console.log(results)
}
})
}
users();
user_by_gender();
// run the query once, and execute the callback of users and user_by_gender.
invalidateCquery("users");
[soon]
[soon]
If you propose hotfixes or new features, I will integrate them as a best effort. As the library is experimental I would prefer discuss them on discord. You can join me on it.
MIT License
Copyright (c) 2022 Arcellier Fabien
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
powerful asynchronous data fetching management for vanillajs
We found that @fabienarcellier/cached-query 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.

Security News
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.