Best way to make data source of a component reactive

Say I have a select2 component in my app and I want its data source to be reactive, the data source can be extract from a collection. What I want is when the collection is updated the data source can be updated as well without reloading the page (Reactive). The problem is the only time I can init the select2 is in the Template.onRendered method, which is called only once in the first place.
The only solution I think of is findding a method to update select2 data source and put it in Template.autorun like this:

    var dataSource = extract ( Meteor.Collection );
    updateSelect2DataSource (dataSource);

Is it a good approach ?

I think it is (the exact syntax is this.autorun inside onRendered).

1 Like