Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

funooks

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funooks - npm Package Compare versions

Comparing version 0.0.1-alpha.0 to 0.0.1

5

package.json
{
"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"

96

README.md
# 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc