Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
qwik-simurgh
Advanced tools
Readme
An asynchronous state manager for Qwik - similar to the excellent libraries of Tanstack Query.
useInfiniteQuery()
useMutation()
pnpm add qwik-simurgh
yarn add qwik-simurgh
npm install qwik-simurgh
SimurghProvider
context provider + the store that will hold the cached
queries:// src/routes/layout.tsx
import {component$, Slot} from "@builder.io/qwik";
import type {RequestHandler} from "@builder.io/qwik-city";
import {InMemoryCacheStore, SimurghProvider} from "qwik-simurgh";
export const onGet: RequestHandler = async ({cacheControl}) => {
/* ... */
};
export default component$(() => {
return (
<SimurghProvider store$={() => new InMemoryCacheStore()}>
<Slot/>
</SimurghProvider>
);
});
import {$, component$, useSignal} from "@builder.io/qwik";
import {useQuery} from "qwik-simurgh";
export default component$(() => {
const search = useSignal<string | undefined>("");
const {data, isLoading, isSuccess, isError, errors} = useQuery<string, string, any>({
queryKey: [search],
queryFn$: $(() =>
fetch("https://fakestoreapi.com/products/" + search.value)
.then((res) => res.text())),
select$: $((res: any) => res),
refetchOnWindowFocus: false,
staleTime: 30 * 1000
});
return <div class="m-12 flex flex-col gap-1">
<h1 class="text-3xl">🐦 Simurgh </h1>
<input class="rounded-md border-2 border-blue-400 px-2 py-1 hover:border-blue-700"
value={search.value}
onInput$={(e) => (search.value = e.target?.value)}
/>
{isLoading.value && <div>Loading data...</div>}
{isSuccess.value && <div> Data :{data.value}</div>}
</div>
});
Automatic refetching when search value changes; fetches from cache after the initial request until for the duration of the cache window
worker$()
SHA512
hash of some value on a separate worker threadimport {component$, useSignal} from "@builder.io/qwik";
import {useQuery} from "qwik-simurgh";
import {worker$} from "@builder.io/qwik-worker";
import {computeHash} from "@/hasher"
export default component$(() => {
const text = useSignal<string>(/* ... */)
const {data} = useQuery<string, string, any>({
queryKey: ["hash", text],
queryFn$: worker$(async () => await computeHash(text.value, "SHA512")),
})
return <>{/* ... */}</>
})
server$()
import {component$} from "@builder.io/qwik";
import {server$} from "@builder.io/qwik-city";
import {useQuery} from "qwik-simurgh";
import {db} from "@/db"
export default component$(() => {
const {data} = useQuery<string, string, any>({
queryKey: ["products"],
queryFn$: server$(async () => await db.findAll()),
})
return <>{/* ... */}</>
})
routeLoader$()
with useQuery
initialData
import {$, component$, useSignal} from "@builder.io/qwik";
import {routeLoader$, useLocation} from "@builder.io/qwik-city";
import {useQuery} from "qwik-simurgh";
const useProduct = routeLoader$<Product>(async (req) => {
const product = await fetch("https://fakestoreapid.com/products/" + req.query.get("productId"))
return await product.json() as Product
});
export default component$(() => {
const preloadedProduct = useProduct()
const location = useLocation()
const selectedProductId = useSignal<string>(location.url.searchParams.get("productId"))
const {data} = useQuery<string, string, any>({
queryKey: ["product", selectedProductId],
initialQueryKey: ["product", location.url.searchParams.get("productId")],
initialData: preloadedProduct.value,
queryFn$: $(() => fetch("https://fakestoreapi.com/products/" + location.url.searchParams.get("productId"))
.then(res => res.json())),
})
return <>{/* ... */}</>
})
Make sure to set initialQueryKey
to a value that matches queryKey
initial
state, useQuery
will skip calling the query function altogether & uses the preloaded route data directly.
FAQs
Async State Manager for Qwik similar to Tanstack's React Query
The npm package qwik-simurgh receives a total of 5 weekly downloads. As such, qwik-simurgh popularity was classified as not popular.
We found that qwik-simurgh demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.