├── .gitignore
├── .npmignore
├── .npmrc
├── .travis.yml
├── LICENSE
├── README.md
├── async.js
├── cjs
├── async.js
├── context.js
├── e.js
├── effect.js
├── extras.js
├── hooks.js
├── index.js
├── memo.js
├── package.json
├── reducer.js
└── ref.js
├── e.js
├── es.js
├── esm.js
├── esm
├── async.js
├── context.js
├── e.js
├── effect.js
├── extras.js
├── hooks.js
├── index.js
├── memo.js
├── reducer.js
└── ref.js
├── index.js
├── package.json
├── rollup
├── async.config.js
├── es.config.js
├── esm.config.js
└── index.config.js
├── test
├── async.html
├── context.html
├── context.js
├── e.js
├── index.js
├── multi.html
├── package.json
└── timer.js
└── uhooks.jpg
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .nyc_output
3 | node_modules/
4 | coverage/
5 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .nyc_output
3 | .travis.yml
4 | node_modules/
5 | rollup/
6 | test/
7 | coverage/
8 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - stable
4 | git:
5 | depth: 1
6 | branches:
7 | only:
8 | - main
9 | after_success:
10 | - "npm run coveralls"
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | ISC License
2 |
3 | Copyright (c) 2020, Andrea Giammarchi, @WebReflection
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any
6 | purpose with or without fee is hereby granted, provided that the above
7 | copyright notice and this permission notice appear in all copies.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 | PERFORMANCE OF THIS SOFTWARE.
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # µhooks
2 |
3 | [](https://travis-ci.com/WebReflection/uhooks) [](https://coveralls.io/github/WebReflection/uhooks?branch=main) [](https://webreflection.github.io/csp/#-csp-strict)
4 |
5 | 
6 |
7 | **Social Media Photo by [Tatiana Rodriguez](https://unsplash.com/@tata186) on [Unsplash](https://unsplash.com/)**
8 |
9 | ### 📣 Community Announcement
10 |
11 | Please ask questions in the [dedicated discussions repository](https://github.com/WebReflection/discussions), to help the community around this project grow ♥
12 |
13 | ---
14 |
15 | _micro hooks_ is a simplified _~0.8K_ alternative to [augmentor](https://github.com/WebReflection/augmentor#readme), with the following differences:
16 |
17 | * `hooked(fn)` is the *augmentor* entry point equivalent
18 | * multiple states update are applied at once asynchronously (these are a *Promise.then(...)* away)
19 | * `useEffect` is also applied asynchronously
20 | * there are no extra options whatsoever so it's less configurable
21 | * there is no `contextual` export, as every hook can have a context passed along, whenever it's needed, or a good idea at all
22 | * exports from `uhooks/async` allows `hooked(async () => { ... })` definitions
23 | * the [uhooks/e](./esm/e.js) export provides an *essential* utility with `useState` and `useRef`, usable in micro-controllers or whenever synchronous, simplified, hooks are enough, and code size/memory constraints are relevant.
24 |
25 | The reason for this module to exist is to explore a slightly different pattern that is *not* stack-based, but that should perform overall better in real-world use cases, thanks to its smaller size and its reduced amount of invokes applied in bulks.
26 |
27 | ```js
28 | //
23 |
24 |
25 |
26 |
27 |