hooks.km 429 B

1234567891011121314151617181920
  1. type Hook[T]
  2. &(&(T) => Component) => Component;
  3. export function use:[T]
  4. &(Hook[T], &(T) => Component) => Component
  5. &(hook, k) => { hook(k) };
  6. export function State:[T]
  7. &(T) => Hook[Reactive[T]]
  8. &(initial) => &(k) =>
  9. \ r := sync { Reactive initial },
  10. { k(r) };
  11. export function Effect:
  12. &(Async[never]) => Hook[unit]
  13. &(effect) => &(k) =>
  14. { k() }
  15. .{ with effect };