@typedly/hooks
v2.0.0
Published
A TypeScript type definitions package for managing hooks.
Downloads
8
Maintainers
Readme
@typedly/hooks
A TypeScript type definitions package for managing hooks @typescript-package/hooks.
Table of contents
Installation
The package
npm install @typedly/hooks --save-peerApi
import {
// Lifecycle.
// After.
AfterAllHook,
AfterEachHook,
// Before.
BeforeAllHook,
BeforeEachHook,
AddHook,
ChangeHook,
ClearHook,
DeleteHook,
DestroyHook,
GetHook,
LockHook,
ReplaceHook,
SetHook,
UnlockHook,
UpdateHook,
// Specialized for properties.
PropertyChangeHook,
SetPropertyHook,
// Composite.
Hooks,
ObjectHooks,
// Types.
AllHooks,
HookNames
} from '@typedly/hooks';Interface
AfterAllHook
The shape of the after all hook.
import { AfterAllHook } from '@typedly/hooks';AfterEachHook
The shape of the after each hook.
import { AfterEachHook } from '@typedly/hooks';BeforeAllHook
The shape of the before all hook.
import { BeforeAllHook } from '@typedly/hooks';BeforeEachHook
The shape of the before each hook.
import { BeforeEachHook } from '@typedly/hooks';AddHook
The AddHook interface defines a Lifecycle hook for managing the addition of item of type T.
import { AddHook } from '@typedly/hooks';ClearHook
The shape of the clear hook.
import { ClearHook } from '@typedly/hooks';DeleteHook
The shape of the delete hook.
import { DeleteHook } from '@typedly/hooks';GetHook
The shape of the get hook.
import { GetHook } from '@typedly/hooks';LockHook
The shape of the lock hook.
import { LockHook } from '@typedly/hooks';ReplaceHook
The shape of the replace hook.
import { ReplaceHook } from '@typedly/hooks';ChangeHook
The ChangeHook interface defines a lifecycle hook for managing changes of an object of type T.
import { ChangeHook } from '@typedly/hooks';DestroyHook
The DestroyHook interface defines a lifecycle hook for managing the destruction of an object of type T.
import { DestroyHook } from '@typedly/hooks';Hooks
The Hooks interface defines a set of lifecycle hooks for managing changes and destruction of an object of type T.
import { Hooks } from '@typedly/hooks';
class SampleClass<T extends number> implements Hooks<T> {
public onChange(callbackfn?: ((value: T, oldValue: T) => void) | undefined): this {
return this;
}
public onDestroy(callbackfn?: (() => void) | undefined): this {
return this;
}
public onSet(callbackfn?: ((value: T, oldValue?: T) => T) | undefined): this {
return this;
}
}ObjectHooks
The ObjectHooks interface defines a set of lifecycle hooks for managing changes to properties of an object of type T.
import { ObjectHooks } from '@typedly/hooks';
class SampleClass<T extends { 'someKey': any }> implements ObjectHooks<T> {
public onPropertyChange<K extends keyof T>(key: K, callbackfn?: ((value: T[K], oldValue: T[K]) => void) | undefined): this {
return this;
}
public onSetProperty<K extends keyof T>(key: K, callbackfn?: ((value: T[K], oldValue: T[K]) => T[K]) | undefined): this {
return this;
}
}PropertyChangeHook
The PropertyChangeHook interface defines a lifecycle hook for managing changes to specific properties of an object of type T.
import { PropertyChangeHook } from '@typedly/hooks';SetHook
The SetHook interface defines a lifecycle hook for managing the setting of a value of type T.
import { SetHook } from '@typedly/hooks';SetPropertyHook
The SetPropertyHook interface defines a lifecycle hook for managing the setting of a property value of an object of type T.
import { SetPropertyHook } from '@typedly/hooks';UnlockHook
The shape of the unlock hook.
import { UnlockHook } from '@typedly/hooks';UpdateHook
The shape of update hook.
import { UpdateHook } from '@typedly/hooks';Type
AllHooks
The all hooks type.
import { AllHooks } from '@typedly/hooks';HookNames
import { HookNames } from '@typedly/hooks';Contributing
Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.
Support
If you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.
Support via:
or via Trust Wallet
Thanks for your support!
Code of Conduct
By participating in this project, you agree to follow Code of Conduct.
GIT
Commit
Versioning
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
FAQ How should I deal with revisions in the 0.y.z initial development phase?
The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.
How do I know when to release 1.0.0?
If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.
License
MIT © typedly (license)
Related packages
- @typescript-package/chain-descriptor: A TypeScript library for chain property descriptor.
- @typescript-package/controlled-descriptor: A TypeScript library for controlled property descriptor.
- @typescript-package/controller: A TypeScript package with for various kind of controllers.
- @typescript-package/descriptor-chain: A TypeScript library for property descriptor chain.
- @typescript-package/descriptor: A TypeScript library for property descriptor.
- @typescript-package/descriptors: A TypeScript library for property descriptors.
- @typescript-package/property: A TypeScript package with features to handle object properties.
- @typescript-package/wrap-descriptor: A TypeScript package for wrapping object descriptors.
- @typescript-package/wrap-property: A TypeScript package for wrapping object properties.
- @typescript-package/wrapped-descriptor: A lightweight TypeScript library for wrapped property descriptor.
- @xtypescript/property - A comprehensive, reactive TypeScript library for precise and extensible object property control.
