NativeSampleTurboModule.js 1007 B

123456789101112131415161718192021222324252627282930313233343536
  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. * @flow
  8. * @format
  9. */
  10. 'use strict';
  11. import type {TurboModule} from '../RCTExport';
  12. import * as TurboModuleRegistry from '../TurboModuleRegistry';
  13. export interface Spec extends TurboModule {
  14. // Exported methods.
  15. +getConstants: () => {|
  16. const1: boolean,
  17. const2: number,
  18. const3: string,
  19. |};
  20. +voidFunc: () => void;
  21. +getBool: (arg: boolean) => boolean;
  22. +getNumber: (arg: number) => number;
  23. +getString: (arg: string) => string;
  24. +getArray: (arg: Array<any>) => Array<any>;
  25. +getObject: (arg: Object) => Object;
  26. +getValue: (x: number, y: string, z: Object) => Object;
  27. +getValueWithCallback: (callback: (value: string) => void) => void;
  28. +getValueWithPromise: (error: boolean) => Promise<string>;
  29. }
  30. export default (TurboModuleRegistry.getEnforcing<Spec>(
  31. 'SampleTurboModule',
  32. ): Spec);