Skip to content

Commit 4e13f9f

Browse files
committed
[WB-2281] Address feedback
1 parent 40c66a0 commit 4e13f9f

6 files changed

Lines changed: 10 additions & 12 deletions

File tree

__docs__/wonder-blocks-timing/use-action-scheduler.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Meta, Canvas} from "@storybook/addon-docs/blocks";
77
# `useActionScheduler`
88

99
`useActionScheduler` is a hook-based alternative to the `withActionScheduler`
10-
higher-order component. It returns an [`IScheduleActions`](#ischeduleactions)
10+
higher-order component. It returns an `IScheduleActions`
1111
instance that automatically clears all pending actions when the component
1212
unmounts.
1313

__docs__/wonder-blocks-timing/use-animation-frame.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cancelling animation frames. It is defined as follows:
1111

1212
```ts
1313
function useAnimationFrame(
14-
action: () => unknown,
14+
action: (time: DOMHighResTimeStamp) => unknown,
1515
options?: {
1616
schedulePolicy?: SchedulePolicy,
1717
clearPolicy?: ClearPolicy,

packages/wonder-blocks-timing/src/hooks/__tests__/use-action-scheduler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {useActionScheduler} from "../use-action-scheduler";
55

66
describe("useActionScheduler", () => {
77
beforeEach(() => {
8-
// Exclude rAF/cAF from sinon's fake timers so our spies wrap jsdom's
8+
// Exclude rAF/cAF from jest's fake timers so our spies wrap jsdom's
99
// originals. After restoreAllMocks(), RTL auto-cleanup calls jsdom's
1010
// cancelAnimationFrame (which safely ignores unknown IDs) rather than
11-
// sinon's fake (which throws when given a setTimeout ID).
11+
// jest's fake (which throws when given a setTimeout ID).
1212
jest.useFakeTimers({
1313
doNotFake: ["requestAnimationFrame", "cancelAnimationFrame"],
1414
});

packages/wonder-blocks-timing/src/hooks/__tests__/use-animation-frame.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {useAnimationFrame} from "../use-animation-frame";
66

77
describe("useAnimationFrame", () => {
88
beforeEach(() => {
9-
// Exclude rAF/cAF from sinon's fake timers so our spies wrap jsdom's
9+
// Exclude rAF/cAF from jest's fake timers so our spies wrap jsdom's
1010
// originals. After restoreAllMocks(), RTL auto-cleanup calls jsdom's
1111
// cancelAnimationFrame (which safely ignores unknown IDs) rather than
12-
// sinon's fake (which throws when given a setTimeout ID).
12+
// jest's fake (which throws when given a setTimeout ID).
1313
jest.useFakeTimers({
1414
doNotFake: ["requestAnimationFrame", "cancelAnimationFrame"],
1515
});

packages/wonder-blocks-timing/src/hooks/use-action-scheduler.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ import ActionScheduler from "../util/action-scheduler";
2929
export function useActionScheduler(): IScheduleActions {
3030
const schedulerRef = useRef<ActionScheduler | null>(null);
3131

32-
if (schedulerRef.current === null) {
33-
schedulerRef.current = new ActionScheduler();
34-
}
35-
3632
useEffect(() => {
33+
schedulerRef.current = new ActionScheduler();
3734
return () => {
3835
schedulerRef.current?.disable();
3936
schedulerRef.current = null;

packages/wonder-blocks-timing/src/hooks/use-animation-frame.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import AnimationFrame from "../util/animation-frame";
2222
* @param options.clearPolicy Determines how the request is cleared when the
2323
* component is unmounted or the request is recreated. By default, the
2424
* request is cancelled immediately. If you want to let the request run to
25-
* completion, use `ClearPolicy.Resolve`. This is NOT applied if the request
26-
* is cleared manually via the `clear()` method on the returned API.
25+
* completion, use `ClearPolicy.Resolve`. This policy is also used as the
26+
* default when calling `clear()` manually with no argument. Pass an explicit
27+
* `ClearPolicy` to `clear(policy)` to override it for a specific call.
2728
* @param options.schedulePolicy Determines when the request is scheduled.
2829
* By default, the request is made immediately. If you want to delay
2930
* scheduling the request, use `SchedulePolicy.OnDemand`.

0 commit comments

Comments
 (0)