Skip to content

Services

See also

For an introduction to using services in components, see the Services guide. For architecture details, see Service Architecture.

Services will help you implement common tasks by abstracting their tedious parts. A service will always have 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 requestAnimationFrame features
  • useResize to implement window resize features
  • useScroll to implement scroll features

MIT Licensed