1
0

hooks.txt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. CORE
  2. ====
  3. core | use_hook | Store a value between renders. The foundational hook for all other hooks.
  4. LIFECYCLE
  5. =========
  6. hooks | use_effect | Run closure after the component has finished rendering.
  7. core | use_drop | Creates a callback that will be run before the component
  8. hooks | use_on_unmount | DEPRECATED. Alias for use_drop.
  9. core | use_hook_with_cleanup | Like `use_hook` and `use_drop` combined
  10. core | use_before_render | Safely handle "early returns"
  11. core | use_after_render | Safely handle "early returns" HOW DOES THIS DIFFER FROM `before_render`?
  12. LOCAL STATE
  13. ===========
  14. hooks | use_signal | Creates a new Signal (state with automatic dependency tracking)
  15. hooks | use_memo | Creates a new Memo. Eefficiently compute derived data from signals.
  16. Advanced:
  17. hooks | use_signal_sync | Creates a new Signal that is `Send + Sync`
  18. hooks | use_set_compare | Creates a new SetCompare which efficiently tracks when a value changes to check if it is equal to a set of values.
  19. hooks | use_set_compare_equal | A hook that returns true if the value is equal to the value in the set compare.
  20. CALLBACK (closed over state)
  21. ========
  22. hooks | use_callback | Create a callback that’s always up to date. Whenever this hook is called the inner callback will be replaced with the new callback but the handle will remain.
  23. NON-LOCAL STATE
  24. ===============
  25. hooks | use_context_provider | Provide some context via the tree and return a reference to it
  26. hooks | use_context | Consume some context in the tree, providing a sharable handle to the value
  27. hooks | try_use_context | Consume some context in the tree, providing a sharable handle to the value
  28. hooks | use_root_context | Try to get a value from the root of the virtual dom, if it doesn’t exist, create a new one with the closure provided.
  29. ASYNC
  30. =====
  31. hooks | use_resource | Derive a value using an future / async closure (re-run each time derived values change).
  32. Advanced:
  33. hooks | use_future | A hook that allows you to spawn a future the first time you render a component.
  34. hooks | use_coroutine | Maintain a handle over a future that can be paused, resumed, and canceled.
  35. hooks | use_coroutine_handle | Get a handle to a coroutine higher in the tree
  36. NOT SURE
  37. ========
  38. hooks | use_reactive | Takes non-reactive data, and a closure and subscribes to that non-reactive data as if it were reactive.
  39. hooks | use_hook_did_run | A hook that uses before/after lifecycle hooks to determine if the hook was run