内容简介:Use web workers with react hookBefore you start using thisMore examples:
Use web workers with react hook
https://useworker.js.org/
:art:
Features
- Run expensive function without blocking UI ( Show live gif )
- Supports Promises pattern instead of event-messages
- Size:
< 1KB, withzerodependencies - Clear API using hook
:floppy_disk:
Install
npm install --save @koale/useworker
:hammer:
Import
import { useWorker, WORKER_STATUS } from "@koale/useworker";
:orange_book:
Documents
:bread:
Demo
- Sorting : Sorting 50000 random numbers
- Csv : Generate Csv, Parse Csv, Convert to JSON
- External Dependencies Use external scripts inside WebWorkers
⚙ Web Workers
Before you start using this hook , I suggest you to read the Web Worker documentation.
:feet:
Usage
import React from "react";
import { useWorker } from "@koale/useworker";
const numbers = [...Array(5000000)].map(e => ~~(Math.random() * 1000000));
const sortNumbers = nums => nums.sort();
const Example = () => {
const [sortWorker] = useWorker(sortNumbers);
const runSort = async () => {
const result = await sortWorker(numbers); // non-blocking UI
console.log("End.");
};
return (
<button type="button" onClick={runSort}>
Run Sort
</button>
);
};
:feet:
Examples
More examples: https://github.com/alewin/useWorker/tree/develop/example
:wrench:
Roadmap
- import and use external script inside
useWorkerfunction - import and use local script inside
useWorkerfunction - run multiple instance of the worker
:earth_asia:
Contribute? Bug? New Feature?
The library is experimental so if you find a bug or would like to request a new feature , open an issue
:bulb:
Similar Project
:scroll:
License
MIT © alewin
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
密码学概论(中文版)
wade trappe、lawrence C.washington / 特拉普 / 人民邮电出版社 / 2004-6-1 / 38.00
本书全面讲解了密码学基本知识以及相关的基础数学理论,介绍了椭圆曲线、AES和量子密码体制等密码学前沿知识,详细地阐述了数字签名、数字现金等应用问题。另外,书中每章均给出了相应的习题,在附录中给出了相关Mathematica、Maple和 MATLAB实例。 本书可供高等院校就用数学、通信和计算机等专业用作密码学、通信安全和网络安全等课程的教材或参考书,也可供信息安全系统设计开发人......一起来看看 《密码学概论(中文版)》 这本书的介绍吧!