Comments (9)
Seems promising, thank you!
from ngx-ui-tour.
Hi,
For now, as a workaround, you could stop the tour before navigating to a different route and then use tourService.startAt('someStep')
to start the tour at specific step once your data is loaded.
Anyway, something like you describe shouldn't be too hard to implement. Do you think a config waitBeforeShowing: Promise | Observable
should be sufficient in this case?
from ngx-ui-tour.
@fergardi
I have published version 5.1 which includes new waitFor
config. I've also added an example to the demo app. Test it out and let me know if it works as intended.
EDIT: v5.1.1. v5.1 had a bug.
from ngx-ui-tour.
Thanks for the new feature! I tested it on my project and worked just fine.
However, I've found a strange situation. Let's say I've got three steps 1, 2 and 3. The first one is on the route A, and the second and third ones on the route B. Both routes A and B need to wait for async data in order to properly show the tour steps, so I went this way:
this.tourService.initialize([
{
route: '/route/A',
anchorId: 'step1',
title: 'example',
content: 'example',
waitFor: Observable,
},
{
route: '/route/B',
anchorId: 'step2',
title: 'example',
content: 'example',
waitFor: Observable,
},
{
route: '/route/B',
anchorId: 'step3',
title: 'example',
content: 'example',
waitFor: undefined,
}
], options);
Where the Observable
is a Subject
which gets uptated with .next()
when the async data of each route has finished loading. Since the step3 shares routeB with step2, there is no need to waitFor
becase the async data is already checked on previous step2.
But when on step3, if I want to go back to step2, it hangs on waitFor
ing the Observable
again, which was already .next()
ed once we landed on this route B, and wont fire again becase the data was already loaded.
So basically, I got it working when traveling forward through different routes, but within the same route I'm stuck in backwards mode.
How would you overcome this situation? I've already tried with Promises
instead of Observables
, with no luck so far.
Thanks in advance.
from ngx-ui-tour.
You need to use ReplaySubject instead of plain Subject
.
from ngx-ui-tour.
Now I see the issue with using Subject
instead of ReplaySubject
. Thanks for the insight.
Unfortunatelly this does not solve my specific problem, because I linked all my steps to the same ReplaySubject
, hence only triggering the desired effect on the first step with a waitFor
.
I guess I could make an array of ReplaySubject[]
, and next()
ing the specific ones I need as I progress further into my app, but that seems tedious and non scalable.
Since I'm using Firebase as a backend, I am only missing my heights calculations by milliseconds. For example, a list populated with *ngFor
after a table database subscription, hence the backdrop miscalculation as soon as the tour step enters on the route.
I've tried to waitFor
a setTimeout
ed promise, but as the steps are created on initialization, I'm guessing they all resolve at the same time, instead of before next step invocation:
{
route: '/route/B',
anchorId: 'step2',
title: 'example',
content: 'example',
waitFor: new Promise(resolve => setTimeout(resolve, 1000))
},
Normally I would solve this kind of problem using the setTimeout(fn, 0)
stack hack ($nextTick()
on VueJS), but I'm out of ideas. Any thoughts?
Thanks!
from ngx-ui-tour.
You can use different subjects and find the subject you need to resolve in the TourService
:
const myStep = this.tourService.steps.find(step => step.anchorId === 'my-step');
myStep.waitFor.next();
from ngx-ui-tour.
If you want to find a really scalable way. I would suggest looking into Akita state management pattern. With Akita you should be able to just use loaders without any need to manually resolve your waitFor
observables. For example, here is a simple example:
postsWaitFor = this.loader.loadersFor('posts').get$.pipe(filter(isLoading => isLoading === false));
from ngx-ui-tour.
@fergardi I have introduced a new step option called isAsync
. Should be easier to use. Check out the release info to find out more.
from ngx-ui-tour.
Related Issues (20)
- 🐞 - the library fails to build when TypeScript `strict` mode is enabled HOT 3
- 🐞 - [v9] incorrect scroll position when going to previous step HOT 4
- 🚀 - Additional parameter for hideTourStep to indicate if the next or previous step is already available. HOT 7
- 🐞 - Backdrop is not positioned properly when developer console is opened HOT 10
- 🚀 - Tour should be cancelled when the target element is destroyed. HOT 10
- 🐞 - HOT 9
- 🐞 - `currentStep` is undefined after calling `tourService.start()` HOT 6
- 🚀 - Add support for `prime-ng` library HOT 3
- 🚀 - Add `asyncStepTimeout` setting HOT 1
- 🐞 - Backdrop taller than scroll container when anchor element exceeds scroll container's height HOT 3
- 🚀 - Replace centerAnchorOnScroll by postitionAnchorOnScroll HOT 3
- 🐞 - [md-menu] `nextOnAnchorClick` not working with `closeOnOutsideClick` HOT 1
- 🚀 - Change Defaults Override HOT 1
- 🚀 - Support Angular 17 HOT 1
- 🐞 - [Ionic] tour end button is not working for one of the tour steps HOT 6
- 🐞 - [service] Tour won't open again after pressing the "prev" button and then closing it (with optional first step) HOT 2
- 🐞 - Ionic Version 3 doesn't support Ionic Non-Standalone Ionic Apps HOT 6
- 🚀 - Multi Tour and Execute function before loading step. HOT 9
- 🚀 - Implement route for previous button navigation HOT 4
- 🐞 - [NGX-UI-TOUR-MD-MENU] close tour does not work with RouterModule.forRoot HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-ui-tour.