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

hooks for functions

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

FunHooks

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?

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.

FAQs

Package last updated on 22 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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