Skip to content
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

Add ability to watch a key for changes #13

Open
AtkinsSJ opened this issue Mar 19, 2024 · 0 comments
Open

Add ability to watch a key for changes #13

AtkinsSJ opened this issue Mar 19, 2024 · 0 comments

Comments

@AtkinsSJ
Copy link

It's often useful to be able to run a callback whenever a certain value changes. For example, maybe whenever the user's timezone changes, different parts of the app want to react in different ways to update clocks and other things.

For example:

const kvjs = require('@heyputer/kv.js');

// Create a new kv.js instance
const kv = new kvjs();

// Watch the key for changes
kv.watch('foo', value => {
	console.log('foo changed!', value);
});

// Set a key
kv.set('foo', 42);

// Console will log 'foo changed! 42'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant