1 import UIKit
2 
3 // MARK: - Module name
4 
5 /**
6  Sets the name of the module that is exported to the JavaScript world.
7  */
Namenull8 public func Name(_ name: String) -> AnyDefinition {
9   return ModuleNameDefinition(name: name)
10 }
11 
12 // MARK: - Module's lifecycle
13 
14 /**
15  Creates module's lifecycle listener that is called right after module initialization.
16  */
17 public func OnCreate(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
18   return EventListener(.moduleCreate, closure)
19 }
20 
21 /**
22  Creates module's lifecycle listener that is called when the module is about to be deallocated.
23  */
24 public func OnDestroy(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
25   return EventListener(.moduleDestroy, closure)
26 }
27 
28 /**
29  Creates module's lifecycle listener that is called when the app context owning the module is about to be deallocated.
30  */
31 public func OnAppContextDestroys(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
32   return EventListener(.appContextDestroys, closure)
33 }
34 
35 /**
36  Creates a listener that is called when the app is about to enter the foreground mode.
37  */
38 public func OnAppEntersForeground(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
39   return EventListener(.appEntersForeground, closure)
40 }
41 
42 /**
43  Creates a listener that is called when the app becomes active again.
44  */
45 public func OnAppBecomesActive(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
46   return EventListener(.appBecomesActive, closure)
47 }
48 
49 /**
50  Creates a listener that is called when the app enters the background mode.
51  */
52 public func OnAppEntersBackground(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
53   return EventListener(.appEntersBackground, closure)
54 }
55 
56 // MARK: - View Manager
57 
58 /**
59  Creates the view manager definition that scopes other view-related definitions.
60  */
61 public func ViewManager(@ViewManagerDefinitionBuilder _ closure: @escaping () -> ViewManagerDefinition) -> AnyDefinition {
62   return closure()
63 }
64