Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a new hook useBackgroundQueue #212

Closed
wants to merge 1 commit into from
Closed

Adds a new hook useBackgroundQueue #212

wants to merge 1 commit into from

Conversation

gremo
Copy link

@gremo gremo commented Jul 26, 2022

Allow use of window.requestIdleCallback()` APIs easily in controllers.

Resolves #209

Copy link
Member

@marcoroth marcoroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @gremo, thanks for opening this!

This is already looking good! I think we should stick closer to the actual API name, because otherwise it might get kinda confusing. I would probably go with something like useRequestIdle() or useRequestIdleCallback().

I also left a few comments

.all-contributorsrc Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved

```js
export default class extends ApplicationController {
static debounces = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to make it match the other one

Suggested change
static debounces = [
static queue = [

but I'm also not sure if this name isn't a bit misleading. I'd vote for static idleCallbacks = []

const defaultOptions = {}
const idleCallbackIds: number[] = []

const ric = (fn: Function, maxWait?: number) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should define window.requestIdleCallback if it's not defined already instead of wrapping it in a function and returning the function.

As it's outlined in the article you mentioned here.

Allow use of window.requestIdleCallback()` APIs easily in controllers
@gremo gremo closed this by deleting the head repository Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce useRequestIdleCallback optimization hook
2 participants