Skip to content

Commit fd871e0

Browse files
authored
mocking pop event handler (#7961)
* mocking pop event handler * fix * Update ComponentScreen.tsx
1 parent 689481e commit fd871e0

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/Mock/Stores/EventsStore.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ComponentDidDisappearEvent,
33
ComponentWillAppearEvent,
44
ModalDismissedEvent,
5+
ScreenPoppedEvent,
56
} from '../../src/interfaces/ComponentEvents';
67
import { ComponentDidAppearEvent, NavigationButtonPressedEvent } from '../../src/index';
78
import { BottomTabPressedEvent, CommandCompletedEvent } from '../../src/interfaces/Events';
@@ -14,6 +15,8 @@ export const events = {
1415
modalDismissed: [(_event: ModalDismissedEvent) => {}],
1516
bottomTabPressed: [(_event: BottomTabPressedEvent) => {}],
1617
commandCompleted: [(_event: CommandCompletedEvent) => {}],
18+
screenPopped: [(_event: ScreenPoppedEvent) => {}],
19+
1720
invokeComponentWillAppear: (event: ComponentWillAppearEvent) => {
1821
events.componentWillAppear &&
1922
events.componentWillAppear.forEach((listener) => {
@@ -56,4 +59,10 @@ export const events = {
5659
listener(event);
5760
});
5861
},
62+
invokeScreenPopped: (event: ScreenPoppedEvent) => {
63+
events.screenPopped &&
64+
events.screenPopped.forEach((listener) => {
65+
listener(event);
66+
});
67+
},
5968
};

lib/Mock/mocks/NativeCommandsSender.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export class NativeCommandsSender {
5555
LayoutStore.getLayoutById(componentId).getStack().children
5656
) as ComponentNode;
5757
LayoutStore.pop(componentId);
58+
events.invokeScreenPopped({
59+
componentId,
60+
});
5861
resolve(poppedChild.nodeId);
5962
this.reportCommandCompletion(CommandName.Pop, commandId);
6063
});

lib/Mock/mocks/NativeEventsReceiver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ export class NativeEventsReceiver {
152152
}
153153

154154
public registerScreenPoppedListener(
155-
_callback: (event: ScreenPoppedEvent) => void
155+
callback: (event: ScreenPoppedEvent) => void
156156
): EmitterSubscription {
157+
events.screenPopped.push(callback);
157158
return {
158159
remove: () => {},
159160
} as EmitterSubscription;

0 commit comments

Comments
 (0)