ReactiveDict is no more?

ReactiveDict is no longer mentioned in the official API docs, apart from in some change logs? Is it to be part of history?

I might be doing something wrong, but the reactivity in the Dict is not what I expect

template.onCreate:


this.selectedTicketsDict = new reactiveDict()

event

"change #selectedTickets": function(e,t){
        e.target.checked ? t.selectedTicketsDict.set(e.target.value,  true) : t.selectedTicketsDict.delete(e.target.value);
    
    }

helper:

 selectedTicketsCount: function(){
        return Object.keys(Template.instance().selectedTicketsDict.keys).length;
    }

the helper is in this situation static, does not react to the changes in the selectedTicketsDict, not reactive

If I instead do:

onCreate
this.selectedTicketsCount = new ReactiveVar(0);

event:
"change #deployment selectedTickets": function(e,t){
        e.target.checked ? t.selectedTicketsDict.set(e.target.value,  true) : t.selectedTicketsDict.delete(e.target.value);
        t.selectedTicketsCount.set(Object.keys(t.selectedTicketsDict.keys).length)
    }

and the helper:

 selectedTicketsCount: function(){
       
        //return Object.keys(Template.instance().selectedTicketsDict.keys).length;
        return Template.instance().selectedTicketsCount.get();
    }

Then I get reactivity. I do not see my error.

The .keys attribute is not reactive. You probably want to use .all() (Functions in Meteor are reactive, but attributes are not).:

return Object.keys(Template.instance().selectedTicketsDict.all()).length
2 Likes

Also, I’m not really sure why ReactiveDict (reactive-dict) isn’t documented anymore – I don’t believe it’s deprecated. Do you mind opening an issue on the Meteor Docs repository?

Thanks, that did the trick!