tracker-component
tracker-component copied to clipboard
this.subscriptionsReady() Not Updating
this.autorun(() => { this.setState({ ready: this.subscriptionsReady(),
this.state.ready
once change to false does not update anymore even if I purposely delayed the publication.
Oh, I have to create a test for this, sounds not so great. Thx for noticing!
Yep, having the same problem. If my subscriptions change, this.subscriptionsReady() goes not to true anymore.
@timbrandin any update on this?
@ralphievolt yeah, this has to do with that we're saving the subscriptions with a jsonified object of the name and arguments, this causes it to save a new one for each time it is updated. @elviron has started looking at this, https://github.com/Elviron/tracker-component/commit/2ec758a1badfcb05ac412f608c8db0f988ddded3
We should probably just store per name, I did this before though, and I can't remember why I changed it to store subscriptions with all the arguments. PR's are welcome.
I'm looking forward to a solve on this as well! For those lookin for a bit more detailed code causing this issue. I have an instance with mulitple task lists (variation of the popular todo tutorials). When the setVisibility toggler for one list is changed, showCompleted changes between true and false. This updates the subscription for this list's taskItems but when changing this.subscribe's filters in Meteor's Tracker update this.subscriptionsReady() returns false instead of true causing dispatch(fetchTaskItems(listId)) to never update the store.
this.autorun(()=> {
const {
listId,
showCompleted,
dispatch
} = this.props;
const showAll = showCompleted || showCompleted===undefined? true:false;
const filters = showAll? 'SHOW_ALL':'SHOW_ACTIVE';
this.subscribe('taskItemsForList', listId, filters);
// #FIXME# changing the subscription caused subscriptionsReady() to return false;
if(this.subscriptionsReady()){
dispatch(fetchTaskItems(listId));
}
else {
dispatch(taskItemsSubscriptionPending(listId));
}
});
Any workarounds? I don't understand how to fix this(
Any updates on this?