Explorar el Código

componentDidDisappear

Daniel Zlotin hace 7 años
padre
commit
40c47b754a

+ 1
- 5
lib/src/adapters/Element.tsx Ver fichero

4
 
4
 
5
 let RNNElement: React.ComponentType<any>;
5
 let RNNElement: React.ComponentType<any>;
6
 
6
 
7
-export class Element extends React.Component<{
8
-  elementId: any;
9
-  resizeMode: any;
10
-}, any> {
11
-
7
+export class Element extends React.Component<{ elementId: any; resizeMode: any; }, any> {
12
   static propTypes = {
8
   static propTypes = {
13
     elementId: PropTypes.string.isRequired,
9
     elementId: PropTypes.string.isRequired,
14
     resizeMode: PropTypes.string
10
     resizeMode: PropTypes.string

+ 28
- 2
lib/src/events/EventsRegistry.test.ts Ver fichero

12
 
12
 
13
   it('exposes appLaunch event', () => {
13
   it('exposes appLaunch event', () => {
14
     const subscription = {};
14
     const subscription = {};
15
-    mockNativeEventsReceiver.registerAppLaunched.mockReturnValueOnce(subscription);
16
     const cb = jest.fn();
15
     const cb = jest.fn();
16
+    mockNativeEventsReceiver.registerAppLaunched.mockReturnValueOnce(subscription);
17
+
17
     const result = uut.appLaunched(cb);
18
     const result = uut.appLaunched(cb);
19
+
20
+    expect(result).toBe(subscription);
18
     expect(mockNativeEventsReceiver.registerAppLaunched).toHaveBeenCalledTimes(1);
21
     expect(mockNativeEventsReceiver.registerAppLaunched).toHaveBeenCalledTimes(1);
19
     expect(mockNativeEventsReceiver.registerAppLaunched).toHaveBeenCalledWith(cb);
22
     expect(mockNativeEventsReceiver.registerAppLaunched).toHaveBeenCalledWith(cb);
20
-    expect(subscription).toBe(result);
23
+  });
24
+
25
+  it('exposes componentDidAppear event', () => {
26
+    const subscription = {};
27
+    const cb = jest.fn();
28
+    mockNativeEventsReceiver.registerComponentDidAppear.mockReturnValueOnce(subscription);
29
+
30
+    const result = uut.componentDidAppear(cb);
31
+
32
+    expect(result).toBe(subscription);
33
+    expect(mockNativeEventsReceiver.registerComponentDidAppear).toHaveBeenCalledTimes(1);
34
+    expect(mockNativeEventsReceiver.registerComponentDidAppear).toHaveBeenCalledWith(cb);
35
+  });
36
+
37
+  it('exposes componentDidDisappear event', () => {
38
+    const subscription = {};
39
+    const cb = jest.fn();
40
+    mockNativeEventsReceiver.registerComponentDidDisappear.mockReturnValueOnce(subscription);
41
+
42
+    const result = uut.componentDidDisappear(cb);
43
+
44
+    expect(result).toBe(subscription);
45
+    expect(mockNativeEventsReceiver.registerComponentDidDisappear).toHaveBeenCalledTimes(1);
46
+    expect(mockNativeEventsReceiver.registerComponentDidDisappear).toHaveBeenCalledWith(cb);
21
   });
47
   });
22
 });
48
 });

+ 8
- 0
lib/src/events/EventsRegistry.ts Ver fichero

10
   public appLaunched(callback): EventSubscription {
10
   public appLaunched(callback): EventSubscription {
11
     return this.nativeEventsReceiver.registerAppLaunched(callback);
11
     return this.nativeEventsReceiver.registerAppLaunched(callback);
12
   }
12
   }
13
+
14
+  public componentDidAppear(callback): EventSubscription {
15
+    return this.nativeEventsReceiver.registerComponentDidAppear(callback);
16
+  }
17
+
18
+  public componentDidDisappear(callback): EventSubscription {
19
+    return this.nativeEventsReceiver.registerComponentDidDisappear(callback);
20
+  }
13
 }
21
 }