A TypeScript type definitions package for managing hooks @typescript-package/hooks.
The package
npm install @typedly/hooks --save-peerimport {
// Core.
ChangeHook,
SetHook,
DestroyHook,
// Specialized for properties.
PropertyChangeHook,
SetPropertyHook,
// Composite.
Hooks,
ObjectHooks,
// Types.
AllHooks,
HookNames
} from '@typedly/hooks';The ChangeHook interface defines a lifecycle hook for managing changes of an object of type T.
import { ChangeHook } from '@typedly/hooks';The DestroyHook interface defines a lifecycle hook for managing the destruction of an object of type T.
import { DestroyHook } from '@typedly/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;
}
}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;
}
}The PropertyChangeHook interface defines a lifecycle hook for managing changes to specific properties of an object of type T.
import { PropertyChangeHook } from '@typedly/hooks';The SetHook interface defines a lifecycle hook for managing the setting of a value of type T.
import { SetHook } from '@typedly/hooks';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';The all hooks type.
import { AllHooks } from '@typedly/hooks';import { HookNames } from '@typedly/hooks';Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.
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!
By participating in this project, you agree to follow Code of Conduct.
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.
MIT © typedly (license)
- @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.