Releases: poppinss/hooks
Upgrade to TypeScript 5
- chore: update dependencies 5e03eb0
Full Changelog: v7.1.1-1...v7.1.1-2
Update dependencies
Full Changelog: v7.1.1-0...v7.1.1-1
Update dependencies
Remove providers and executors
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
Rewrite in ESM and refactoring internals
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 likeHooksHandler
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 therunner.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
- chore: update dependencies f340ffd
Update dependencies
- chore: update dependencies 48d47e8
Run cleanup functions in reverse order
Toggle isCleanupPending flag to true only when the hooks have been executed
Update dependencies
- chore: update dependencies cf8466c
Full Changelog: v5.0.0...v5.0.1