UNPKG

react-native-flip

Version:
81 lines (77 loc) 2.15 kB
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow * @format */ 'use strict'; export type FillRateInfo = Info; declare class Info { any_blank_count: number, any_blank_ms: number, any_blank_speed_sum: number, mostly_blank_count: number, mostly_blank_ms: number, pixels_blank: number, pixels_sampled: number, pixels_scrolled: number, total_time_spent: number, sample_count: number, } type FrameMetrics = { inLayout?: boolean, length: number, offset: number, ... }; const DEBUG = false; let _listeners: Array<(Info) => void> = []; let _minSampleCount = 10; let _sampleRate = DEBUG ? 1 : null; /** * A helper class for detecting when the maximem fill rate of `VirtualizedList` is exceeded. * By default the sampling rate is set to zero and this will do nothing. If you want to collect * samples (e.g. to log them), make sure to call `FillRateHelper.setSampleRate(0.0-1.0)`. * * Listeners and sample rate are global for all `VirtualizedList`s - typical usage will combine with * `SceneTracker.getActiveScene` to determine the context of the events. */ declare class FillRateHelper { _anyBlankStartTime: any, _enabled: any, _getFrameMetrics: (index: number) => ?FrameMetrics, _info: any, _mostlyBlankStartTime: any, _samplesStartTime: any, static addListener(callback: (FillRateInfo) => void): { remove: () => void, ... }, static setSampleRate(sampleRate: number): any, static setMinSampleCount(minSampleCount: number): any, constructor(getFrameMetrics: (index: number) => ?FrameMetrics): any, activate(): any, deactivateAndFlush(): any, computeBlankness(props: { data: any, getItemCount: (data: any) => number, initialNumToRender: number, ... }, state: { first: number, last: number, ... }, scrollMetrics: { dOffset: number, offset: number, velocity: number, visibleLength: number, ... }): number, enabled(): boolean, _resetData(): any, } export default FillRateHelper;