Open stealthAngel opened 1 month ago
After trying to find a workaround i have the following solution although it would be nice to just have a method called driveAsync(){
export class DriverService {
private driverInstance: Driver;
private tourPromise: Promise<void> | null = null;
private resolveTourPromise: (() => void) | null = null;
constructor() {}
create(steps: DriveStep[]): void {
this.driverInstance = driver({
popoverClass: 'driverjs-theme',
progressText: 'Step {{current}} of{{total}}',
prevBtnText: '← Previous',
nextBtnText: 'Next →',
doneBtnText: 'Finish',
showProgress: true,
steps: steps,
onDestroyed: () => {
if (this.resolveTourPromise) {
this.resolveTourPromise();
}
},
});
}
public async startTourAsync(): Promise<void> {
if (!this.driverInstance) {
throw new Error(
'Driver instance not initialized. Call create() with steps first.'
);
}
// Create a new promise for this tour
this.tourPromise = new Promise<void>((resolve) => {
this.resolveTourPromise = resolve;
});
// Start the tour
this.driverInstance.drive();
// Wait for the tour to complete
return this.tourPromise;
}
}
// usage
this.driverService.create(driveSteps); //define your steps here
await this.driverService.startTourAsync();
Is it possible to add awaitable tours
sample:
I want this because I need to manage some states during the tour, like activating buttons etc.