Services
See also
For an introduction to using services in components, see the Services guide. For architecture details, see Service Architecture.
Services implement common tasks and hide their repetitive parts. A service always has the following signature:
ts
interface ServiceProps {
[key:string]: any;
}
interface Service {
add: (key:string, fn: (props:ServiceProps) => void) => void;
remove: (key:string) => void;
has: (key:string) => boolean;
props: () => ServiceProps;
}
useService(...args?):Service;The following services are available:
- useDrag to implement drag features
- useKey to implement keyboard features
- useLoad to implement window load features
- useMutation to implement DOM mutation features
- usePointer to implement mouse/touch features
- useRaf to implement
requestAnimationFramefeatures - useResize to implement window resize features
- useScroll to implement scroll features