mirror of
https://github.com/jaandrle/deka-dom-el
synced 2025-07-04 13:32:14 +02:00
🔤 adds debugging
This commit is contained in:
20
docs/components/examples/signals/debugging-console.js
Normal file
20
docs/components/examples/signals/debugging-console.js
Normal file
@ -0,0 +1,20 @@
|
||||
import { S } from "deka-dom-el/signals";
|
||||
|
||||
// Debugging a derived signal
|
||||
const name = S('Alice');
|
||||
const greeting = S(() => {
|
||||
console.log('Computing greeting...');
|
||||
return 'Hello, ' + name.get();
|
||||
});
|
||||
|
||||
// Monitor the derived signal
|
||||
S.on(greeting, value => console.log('Greeting changed to:', value));
|
||||
|
||||
// Later update the dependency
|
||||
name.set('Bob'); // Should trigger computation and listener
|
||||
|
||||
// Console output:
|
||||
// Computing greeting...
|
||||
// Greeting changed to: Hello, Alice
|
||||
// Computing greeting...
|
||||
// Greeting changed to: Hello, Bob
|
Reference in New Issue
Block a user