Skip to content

Commit

Permalink
feat(connectViewport): allow passing a priority
Browse files Browse the repository at this point in the history
  • Loading branch information
garthenweb committed Feb 16, 2020
1 parent 8325ce6 commit 09a0bfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api/ObserveViewport_connectViewport_useViewport.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ This is just a wrapper for the `ObserveViewport` to implement the HOC pattern.
|:---|:---|:---:|:---|
| omit | `['scroll', 'dimensions']` | | Allows to disable scroll or dimensions events for the higher order component |
| deferUpdateUntilIdle | boolean | | Defers to trigger updates until the collector is idle. See [Defer Events](../concepts/defer_events.md). |
| options.priority | `'low'`, `'normal'`, `'high'`, `'highest'` | | Allows to set a priority of the update. See [Defer Events](../concepts/scheduler.md) |

## Example

Expand Down
3 changes: 3 additions & 0 deletions lib/ConnectViewport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';

import { IScroll, IDimensions } from './index';
import ObserveViewport from './ObserveViewport';
import { PriorityType } from './types';

interface IInjectedProps {
scroll?: IScroll | null;
Expand All @@ -13,6 +14,7 @@ type TPropStrings = 'scroll' | 'dimensions';
interface IOptions {
omit?: TPropStrings[];
deferUpdateUntilIdle?: boolean;
priority?: PriorityType;
}

export default function connect(options: IOptions = {}) {
Expand All @@ -34,6 +36,7 @@ export default function connect(options: IOptions = {}) {
disableScrollUpdates={shouldOmitScroll}
disableDimensionsUpdates={shouldOmitDimensions}
deferUpdateUntilIdle={deferUpdateUntilIdle}
priority={options.priority}
>
{({ scroll, dimensions }) => (
<WrappedComponent
Expand Down

0 comments on commit 09a0bfb

Please sign in to comment.