Skip to content

Commit

Permalink
chore: update spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Caele committed Nov 4, 2024
1 parent 80c71d3 commit 9cf1a79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apis/stardust/api-spec/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@
"import { useMemo } from '@nebula.js/stardust';\n// ...\nconst v = useMemo(() => {\n return doSomeHeavyCalculation();\n}), []);"
]
},
"useRef": {
"description": "Creates a reference to a value not needed for rendering\n\nWhile Nebula does not have a virtual DOM, it is still useful\nto have a reference to an object that is retained across\nrenders and in it self does not trigger a render.",
"kind": "function",
"params": [
{
"name": "initialValue",
"description": "The initial value.",
"type": "any"
}
],
"examples": [
"import { useRef } from '@nebula.js/stardust';\n// ...\n// initiate with simple value\nconst timesRendered = useRef(0);\n\nuseEffect(() => {\n render(layout);\n // increments the render counter, a useState would trigger another render\n timesRendered.current += 1;\n},[layout]);"
]
},
"usePromise": {
"description": "Runs a callback function when a dependent changes.\n\nUseful for async operations that otherwise cause no side effects.\nDo not add for example listeners withing the callback as there is no teardown function.",
"templates": [
Expand Down
10 changes: 10 additions & 0 deletions apis/stardust/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ export function useEffect(effect: stardust.EffectCallback, deps?: any[]): void;
*/
export function useMemo<T>(factory: ()=>T, deps: any[]): T;

/**
* Creates a reference to a value not needed for rendering
*
* While Nebula does not have a virtual DOM, it is still useful
* to have a reference to an object that is retained across
* renders and in it self does not trigger a render.
* @param initialValue The initial value.
*/
export function useRef(initialValue: any): void;

/**
* Runs a callback function when a dependent changes.
*
Expand Down

0 comments on commit 9cf1a79

Please sign in to comment.