@torthu/jacketui-trell
v0.0.1
Published
Simple async queue implementation
Readme
JacketUI Trell
Queue for async tasks based on thinking from compassionate components.
Note that this is a pre-release and that the API is not stable.
Installation
Requires Typescript.
npm i --save @torthu/jacketui-trell
Philosophy
We want flexibility in our components and escape hatches in order to solve edge cases and make components truly expandable and reusable.
In order to achieve this we need to create flexible components, meaning expandable and full of escape hatches in order to cater for edge cases.
Usage
import { createQueue } from "@torthu/jacketui-trell";
const queue = createQueue();
const {task, promise} = queue.enqueue({ task: async (abortController) => bring({ method: "GET", url: "https://example.com", abortController })});
promise.then((res) => if(res.ok) console.log(res));
setTimeout(() => {
if(task.status === "pending" || task.status === "running") {
task.abort();
}
}, 5000);Composability and extendability
JacketUI Trell's internals are exposed in order to allow for both composability and extendability. At the inside Trell is simply a JacketUI Store instance with some state, effects and reducers. This means that you can create your own effects, reducers and state and compose them with Trell's internals.
Plugins
Trell ships with some built in plugins: cache, dedup, retry and timeout. These slot right into the trell core to add functionality to the queue.
