Giter Site home page Giter Site logo

Create a generic form about hooks.macro HOT 2 OPEN

yuchi avatar yuchi commented on June 9, 2024
Create a generic form

from hooks.macro.

Comments (2)

adrianhelvik avatar adrianhelvik commented on June 9, 2024

I think a "keyword" could be kind of cool too. Another thing to consider is that some hooks accept more than one function. We need to gather some function signatures of hooks in the wild to determine the best approach.

import { auto } from 'hooks.macro'

customHook(() => {
  foo()
  bar()
}, () => {
  baz()
}, auto)
customHook(() => {
  foo()
  bar()
}, () => {
  baz()
}, [foo, bar, baz])

from hooks.macro.

adrianhelvik avatar adrianhelvik commented on June 9, 2024

I have taken a look at how hooks in the wild and this was a more common use case than having all dependencies in one array:

useCustomHook(funcA, depsA, funcB, depsB)

Maybe a more specific macros would be better? (as this is hard generalize)

import { injectAfterEach, injectAfterAll, skip } from 'hooks.macro'

injectAfterEach(useCustomHook(funcA, funcB, skip(cleanup)))

What do you think? Alternately, auto() could just collect dependencies for the preceeding function as in useCustomHook(funcA, auto, funcB, auto).

from hooks.macro.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.