![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@iceblocktech/tq
Advanced tools
A simple queue, backed by indexeddb, for processing work in the background. Inspired by Resque.
Queue backed by Indexeddb. Inspired by Resque. tq === "the queue"
tq helps you run background jobs in the browser. Jobs and the queue are backed by Indexed DB and Web Workers, so you can run intensive operations without blocking the main thread.
npm i @iceblocktech/tq
or
yarn add @iceblocktech/tq
You can then import the API as follows:
import { register, enqueue } from '@iceblocktech/tq'
At the core of tq
is a Job
. A Job
is a simple object you define in your code. It looks like this:
type JobPriority = "critical" | "normal" | "low";
type Perform = (
ctx: Context,
args: Record<string, unknown>
) => Promise<void>;
interface Job {
name: string;
priority: JobPriority;
perform: Perform | string;
retryOnError?: boolean;
}
Jobs execute in batches on a regular internal, roughly every 10 seconds. A breakdown of a job's fields:
name
is a name you can give your jobpriority
let's you set the priority of this job. tq
maintains a max queue size and will use the job's priority
to determine when to execute the job. If there is no room in the queue, the job will be deferred to the next execution cycle.
critical
jobs will ignore the max queue size and always executenormal
jobs will only execute if there is room in the queue minus any critical jobslow
priority jobs will only execute if there is room in the queue minus any critical and normal jobsperform
is a function that you define. This function will be called when the job executes. A Context
object and the arguments to the function will also be passed inretryOnError
is an optional flag that indicates if the job should retry when it fails. As of now, tq
will only retry jobs 1 additional time. Retried jobs also respect the priority
logic.The tq
API exposes two methods for you to use. Both of these methods will proxy a request to a Web Worker that will perform the actual work.
register(job: Job)
Registers a job with tq
. If a job is not registred, enqueue
'ing such a job is essentially a no-op.
enqueue(jobName: string, args: Record<string, unknown>)
Enqueues a job, executing the job's perform
function at a later time. Any arguments provided will be passed down to the perform
function
The examples
directory contains some examples to get you started. At a high level, you're work flow will be something like this:
// Define a job
const analyticsJob: Job = {
name: "analytics.job",
priority: "critical",
perform: (ctx: context, args: Record<string, unknown>): Promise<void> => {
analytics.track('User Did Something', ...args)
return Promise.resolve()
},
retryOnError: false
}
// Register the job with tq
const resp = register(tq)
console.log(resp) // => "true"
// Enqueue the job at some ppint
enqueue("analytics.job", { userId: 123 });
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
FAQs
A simple queue, backed by indexeddb, for processing work in the background. Inspired by Resque.
The npm package @iceblocktech/tq receives a total of 2 weekly downloads. As such, @iceblocktech/tq popularity was classified as not popular.
We found that @iceblocktech/tq 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.