Skip to content

Services

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
  • usePointer to implement mouse/touch features
  • useRaf to implement requestAnimationFrame features
  • useResize to implement window resize features
  • useScroll to implement scroll features

MIT Licensed