RCTFrameUpdate.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <Foundation/Foundation.h>
  8. @class CADisplayLink;
  9. /**
  10. * Interface containing the information about the last screen refresh.
  11. */
  12. @interface RCTFrameUpdate : NSObject
  13. /**
  14. * Timestamp for the actual screen refresh
  15. */
  16. @property (nonatomic, readonly) NSTimeInterval timestamp;
  17. /**
  18. * Time since the last frame update ( >= 16.6ms )
  19. */
  20. @property (nonatomic, readonly) NSTimeInterval deltaTime;
  21. - (instancetype)initWithDisplayLink:(CADisplayLink *)displayLink NS_DESIGNATED_INITIALIZER;
  22. @end
  23. /**
  24. * Protocol that must be implemented for subscribing to display refreshes (DisplayLink updates)
  25. */
  26. @protocol RCTFrameUpdateObserver <NSObject>
  27. /**
  28. * Method called on every screen refresh (if paused != YES)
  29. */
  30. - (void)didUpdateFrame:(RCTFrameUpdate *)update;
  31. /**
  32. * Synthesize and set to true to pause the calls to -[didUpdateFrame:]
  33. */
  34. @property (nonatomic, readonly, getter=isPaused) BOOL paused;
  35. /**
  36. * Callback for pause/resume observer.
  37. * Observer should call it when paused property is changed.
  38. */
  39. @property (nonatomic, copy) dispatch_block_t pauseCallback;
  40. @end