Skip to content

Add ability to watch a key for changes #13

@AtkinsSJ

Description

@AtkinsSJ

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions