Skip to content

Releases: poppinss/hooks

Upgrade to TypeScript 5

25 Mar 06:05
Compare
Choose a tag to compare
Pre-release
  • chore: update dependencies 5e03eb0

Full Changelog: v7.1.1-1...v7.1.1-2

Update dependencies

11 Mar 05:17
Compare
Choose a tag to compare
Update dependencies Pre-release
Pre-release
  • chore: update dependencies 766cee1
  • chore: update dependencies c7ffb39

Full Changelog: v7.1.1-0...v7.1.1-1

Update dependencies

05 Jan 05:54
Compare
Choose a tag to compare
Update dependencies Pre-release
Pre-release
  • docs(README): fix badge url for github workflow dd9f0a0
  • chore: update dependencies faf9ea0

v7.1.0-0...v7.1.1-0

Remove providers and executors

05 Nov 05:31
Compare
Choose a tag to compare
Pre-release

Removing providers

Both the providers and the executors have been removed in the favor of object based hooks. Object based hooks can serve both the use cases.

The providers were tracked separately from the hooks and therefore their order of execution will always be at the last or the first. It can be mixed with hooks. For example:

hooks.add('saving', () => {
  console.log('first')
})

class SomeProvider {
  saving() {
    console.log('saving')
  }
}
hooks.provider(SomeProvider)

hooks.add('saving', () => {
  console.log('third')
})

The execution output will be

first
third
second

This can be problematic in some edge case scenarios and we want to guarantee the order of execution to be same as the order of defining hooks or providers. Therefore, the providers have been removed

Removing executors

Custom executors were meant to customize how a hook handler should be called. The same can be achieved using object based hooks and wrapping the original hook handler.

Commits

  • refactor: remove providers and executor in favor of object based hooks b756e70

v7.0.0-0...v7.1.0-0

Rewrite in ESM and refactoring internals

01 Nov 06:11
Compare
Choose a tag to compare

This release sits on the last major pre-release and has following breaking changes on top of it.

  • The main export now uses the default export to export the Hooks class. Earlier it was a named export.
  • The types are moved to a separate subpath export.
    // Earlier
    import type { HooksHandler } from '@poppinss/hooks'
    
    // Now
    import type { HooksHandler } from '@poppinss/hooks/types'
  • The Hooks class now allows defining types for the known events well in advance. This makes the class and the underlying methods type safe. As a result, some of the types like HooksHandler needs generics to know the type of the arguments
  • The hooks.runner method does not accept the 2nd argument for ignoring hooks by name. Instead, you should call the runner.without method.
    // Earlier
    hooks.runner('creating', ['hashPassword']).run()
    
    // Now
    hooks.runner('creating').without(['hashPassword']).run()

Rest of the APIs are same, infact a few more methods have been added.

Commits

  • chore: ignore package-lock file 84e84cd
  • ci: fix import url to be cross platform dcfdda7
  • docs(README): grammatical improvements 2eb9845
  • docs: add documentation 87b8b8d
  • refactor: improve events generic type 816f7fd
  • docs(README): initial docs 828aae8
  • feat: add support to register hook providers a6cbe7b
  • refactor: rewrite in TypeScript 378e487

Full Changelog: v6.0.2-0...v7.0.0-0

Update dependencies

04 Apr 11:31
Compare
Choose a tag to compare
  • chore: update dependencies f340ffd

v5.0.2...v5.0.3

Update dependencies

22 Feb 06:40
Compare
Choose a tag to compare
  • chore: update dependencies 48d47e8

v5.0.1...v5.0.2

Run cleanup functions in reverse order

20 Feb 03:59
Compare
Choose a tag to compare
Pre-release
  • refactor: run cleanup functions in reverse order bf1203e
  • chore: update dependencies d3ad28e

v6.0.1-0...v6.0.2-0

Toggle isCleanupPending flag to true only when the hooks have been executed

06 Feb 09:09
Compare
Choose a tag to compare
  • refactor: set isCleanupPending flag to false by default 00c7cda
  • chore: update dependencies e5f174e

v6.0.0-0...v6.0.1-0

Update dependencies

16 Jan 07:57
Compare
Choose a tag to compare
  • chore: update dependencies cf8466c

Full Changelog: v5.0.0...v5.0.1