Skip to content

Commit fc9c24a

Browse files
committed
Add onStop parameter to this.props.start()
1 parent 9b10293 commit fc9c24a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ class HomeScreen {
176176
```
177177

178178
### Triggering the tutorial
179-
Use `this.props.start()` in the root component in order to trigger the tutorial. You can either invoke it with a touch event or in `componentDidMount`. Note that the component and all its descendants must be mounted before starting the tutorial since the `CopilotStep`s need to be registered first.
179+
Use `this.props.start(fromStep, onStop)` in the root component in order to trigger the tutorial. You can either invoke it with a touch event or in `componentDidMount`. Note that the component and all its descendants must be mounted before starting the tutorial since the `CopilotStep`s need to be registered first.
180+
181+
The `onStop` method will be called after a user selects 'Skip' or 'Finish' buttion in the tooltip.
180182

181183
## Contributing
182184
Issues and Pull Requests are always welcome.

src/hocs/copilot.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const copilot = ({
8686
});
8787

8888
startTries = 0;
89+
onStop = null;
8990

9091
mounted = false;
9192

@@ -123,7 +124,7 @@ const copilot = ({
123124
await this.setCurrentStep(this.getPrevStep());
124125
}
125126

126-
start = async (fromStep?: string): void => {
127+
start = async (fromStep?: string, onStop?: () => void): void => {
127128
const { steps } = this.state;
128129

129130
const currentStep = fromStep
@@ -145,11 +146,17 @@ const copilot = ({
145146
await this.setVisibility(true);
146147
this.startTries = 0;
147148
}
149+
150+
this.onStop = onStop;
148151
}
149152

150153
stop = async (): void => {
151154
await this.setVisibility(false);
152155
this.eventEmitter.emit('stop');
156+
157+
if (this.onStop != null) {
158+
this.onStop();
159+
}
153160
}
154161

155162
async moveToCurrentStep(): void {

0 commit comments

Comments
 (0)