Comparing version 0.0.1-alpha.0 to 0.0.1
{ | ||
"name": "funooks", | ||
"version": "0.0.1-alpha.0", | ||
"version": "0.0.1", | ||
"description": "hooks for functions", | ||
"main": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"type": "module", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "build": "tsc" |
# FunHooks | ||
Hooks for functions. | ||
Hooks for functions. | ||
If you are a fan of React hooks and want to use them everywhere, this is the package for you. | ||
## Disclaimer - this is a **WIP**, don't use it in production. do use it to figure out what can be done. | ||
## What's in the box? | ||
### API | ||
- `useFun` - a hook that allows you to use hooks in functions | ||
- `useState` - a hook that allows you to create contextual state in functions | ||
- `useEffect` - a hook that allows you to use effects in functions (effects run on the microtask queue) | ||
- `useMemo` - a hook that allows you to use memoization in functions | ||
- `useRef` - a hook that allows you to create refs in functions | ||
- `useContext` - a hook that allows you to use context value in functions | ||
- `useCallback` - helper hook that allows you to use memoize functions | ||
- `createContext` - a function that allows you to create a context | ||
- `mount` - a function that allows you to mount a function on a key | ||
- `autoMount` - same as `mount` but waits for all suspended functions to resolve | ||
### Functionality | ||
Composition - compose functions like components | ||
Suspense - suspend a function until all its dependencies are resolved | ||
## How does it work? | ||
```js | ||
import { useState, useEffect, mount } from 'funooks'; | ||
function Model() { | ||
const [count, setCount] = useState(0); | ||
const [name, setName] = useState('John'); | ||
useEffect(() => { | ||
console.log('count effect', count); | ||
}, [count]); | ||
useEffect(() => { | ||
console.log('name effect', name); | ||
}, [name]); | ||
return { | ||
setCount, | ||
setName, | ||
}; | ||
} | ||
const model = mount(Model, []); | ||
model.setCount(1); | ||
model.setName('Will'); | ||
``` | ||
## What's missing (currently)? | ||
### API | ||
- `useReducer` - soon to be implemented | ||
- `useImperativeHandle` - will be interesting to implement | ||
### Functionality | ||
- unmounting - the next in queue to be implemented | ||
- live model updates - will be interesting to implement | ||
- aborting - will be interesting to implement | ||
### Docs | ||
- context | ||
- tests as examples | ||
- what is mount key | ||
- how to use the returned value | ||
- useFun - how to use it with refs | ||
- direct function calls vs useFun | ||
- suspense - how it behaves with fallbacks | ||
## FAQ | ||
### Do I need React? | ||
No, you don't. This package is not tied to React in any way. It just uses the same React's hooks API. | ||
### Is this a joke? | ||
No, it's not. It's a serious package that allows you to use hooks in functions. | ||
### Should I use this? | ||
No, you shouldn't. This is a joke package. | ||
### How to contribute? | ||
Try to create interesting cases that will justify the existence of this package. If you have any ideas, please open an issue. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97
Yes
27307
12
95
1