1 
2 /**
3  A protocol for any type-erased module that provides methods used by the core.
4  */
5 public protocol AnyModule: AnyObject {
6   /**
7    The default initializer. Must be public, but the module class does *not* need to
8    define it as it is implemented in protocol composition, see `BaseModule` class.
9    */
10   init(appContext: AppContext)
11 
12   /**
13    A DSL-like function that returns a `ModuleDefinition` which can be built up from module's name, constants or methods.
14    The `@ModuleDefinitionBuilder` wrapper is *not* required in the implementation — it is implicitly taken from the protocol.
15 
16    # Example
17 
18    ```
19    public func definition() -> ModuleDefinition {
20      name("MyModule")
21      method("myMethod") { (a: String, b: String) in
22        "\(a) \(b)"
23      }
24    }
25    ```
26 
27    This example exports the module to the JavaScript world, which can be used as in this snippet ��
28 
29    ```javascript
30    import { NativeModulesProxy } from 'expo-modules-core';
31 
32    await NativeModulesProxy.MyModule.myMethod('Hello', 'World!'); // -> 'Hello World!'
33    ```
34 
35    # Method's result obtained asynchronously
36 
37    If you need to run some async code to get the proper value that you want to return to JavaScript,
38    just specify an argument of type `Promise` as the last one and use its `resolve` or `reject` methods.
39 
40    ```
41    method("myMethod") { (promise: Promise) in
42      DispatchQueue.main.async {
43        promise.resolve("return value obtained in async callback")
44      }
45    }
46    ```
47    */
48   #if swift(>=5.4)
49   @ModuleDefinitionBuilder
50   func definition() -> ModuleDefinition
51   #else
52   func definition() -> ModuleDefinition
53   #endif
54 }
55