-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A command that I can run for a specific lession/chapter without restarting the running command #257
Comments
Oh that's an interesting use case! It does make sense to want to do some cleanup between lessons. Like maybe have a Have you considered creating a custom component for this? I think the following should work well: import { useEffect } from 'react';
import { webcontainer } from 'tutorialkit:core';
export const MyComponent = ({}) => {
useEffect(() => {
(async () => {
const webcontainerInstance = await webcontainer;
webcontainerInstance.fs.rm('/db/tasks.json', { force: true });
})();
}, []);
return null;
}; Then in a ---
type: lesson
---
import { MyComponent } from '@components/MyComponent';
<MyComponent client:load />
(I just noticed that the type of |
I wasn't aware of this option or the api of I did it in a javascript file that I run in a template |
That works too! So your backend is always restarted between lessons? |
I'm using vite to also hotreload my backend: |
Wow I had no idea you could do that with Thanks for sharing ❤️ Are you happy with your current solution then? Or do you think a custom option in TutorialKit would still be needed? |
@Nemikolh I'm inclined to having a |
Don't you mean more like a Or would you expect that command to be executed on the first lesson a user navigates to, before the |
In my use case, I needed it before a lesson starts. |
Ah interesting! I suppose we could expose several "hooks" commands that execute at specific time of the lifecycle of a tutorial. That way it would work for a larger variety of usecase. It would be interesting to get more data before we start working on this though. Let's keep this issue open and see if others would be in need of a similar solution and what they would want. This can definitely be done post-1.0. |
Is your feature request related to a problem?
Sometimes, between steps in my tutorial, I want to do some cleanup or similar operations, and would like to run a command.
Describe the solution you'd like.
Currently there are only prepare command, and main command - I don't want to restart the running main command, I just want to run a command when the lesson / chapter starts (in my case, delete the
./db/tasks.json
file.Describe alternatives you've considered.
I injected javascript to files the user doesn't see at this stage - it's an ah... solution
Additional context
No response
The text was updated successfully, but these errors were encountered: