We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
using the tutorialStore.onDocumentChanged triggers callback immediately because the nanostores subscribe callback seems to work that way.
tutorialStore.onDocumentChanged
subscribe
For example:
const terminal = tutorialStore.terminalConfig.value!.panels[1]; const filePath = '/foo'; tutorialStore.onDocumentChanged(filePath, (document) => { terminal.write(`${document.filePath} changed\n`); });
Expected comparison between old and new document to confirm changes happened
const terminal = tutorialStore.terminalConfig.value!.panels[1]; const filePath = '/foo'; const stopListening = tutorialStore.documents.listen((newDocuments, oldDocuments) => { if (!newDocuments[filePath] || !oldDocuments || !oldDocuments[filePath]) { return; } const oldDocument = oldDocuments[filePath]; const newDocument = newDocuments[filePath]; if (oldDocument.value !== newDocument.value) { queueMicrotask(() => { terminal.write(`${newDocument.filePath} changed\n`); stopListening(); }); } });
https://stackblitz.com/~/github.com/so0k/tutorialkit-terminal-writer
No response
listen
The text was updated successfully, but these errors were encountered:
because the nanostores subscribe callback seems to work that way.
This seems to be the root cause indeed:
store.subscribe(cb) in contrast with store.listen(cb) also call listeners immediately during the subscription. https://github.com/nanostores/nanostores?tab=readme-ov-file#atoms
store.subscribe(cb) in contrast with store.listen(cb) also call listeners immediately during the subscription.
store.subscribe(cb)
store.listen(cb)
https://github.com/nanostores/nanostores?tab=readme-ov-file#atoms
tutorialkit/packages/runtime/src/store/editor.ts
Lines 148 to 173 in 0e7cf3c
The onDocumentChanged is not used internally by TutorialKit, it's only available via the experimental API. Fixing this should be quite risk-free.
onDocumentChanged
Sorry, something went wrong.
No branches or pull requests
Describe the bug
using the
tutorialStore.onDocumentChanged
triggers callback immediately because the nanostoressubscribe
callback seems to work that way.For example:
Expected comparison between old and new document to confirm changes happened
Link to a StackBlitz project which shows the error
https://stackblitz.com/~/github.com/so0k/tutorialkit-terminal-writer
Steps to reproduce
Expected behavior
Screenshots
No response
Platform
Additional context
listen
if we don't want immediate callback?The text was updated successfully, but these errors were encountered: