user3142695
user3142695

Reputation: 17362

remove ReactiveDict values

This is how I define some ReactiveDict variable:

this.templateDictionary = new ReactiveDict();

this.templateDictionary.set( 'type', type );
this.templateDictionary.set( 'size', size );
this.templateDictionary.set( 'bgcolor', bgcolor );
this.templateDictionary.set( 'color', color );

Now I want to remove everything:

this.templateDictionary.set( 'type', undefined );
this.templateDictionary.set( 'size', undefined );
this.templateDictionary.set( 'bgcolor', undefined );
this.templateDictionary.set( 'color', undefined );

But if I do a console.log, I see the variable get the string undefined. So it isn't really removed.

And by the way: Is it possible to set multiple values by one line?

Upvotes: 3

Views: 748

Answers (1)

ffxsam
ffxsam

Reputation: 27793

What you want is:

this.templateDictionary.delete('type');

Though printing it out will still show undefined, but this is normal.

To delete all keys in your dictionary:

this.templateDictionary.clear();

For a list of all the functions in ReactiveDict, check this out.

Upvotes: 3

Related Questions