tracker-component icon indicating copy to clipboard operation
tracker-component copied to clipboard

this.subscriptionsReady() Not Updating

Open ralphievolt opened this issue 8 years ago • 7 comments

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.

ralphievolt avatar Apr 19 '16 02:04 ralphievolt

Oh, I have to create a test for this, sounds not so great. Thx for noticing!

timbrandin avatar Apr 22 '16 12:04 timbrandin

Yep, having the same problem. If my subscriptions change, this.subscriptionsReady() goes not to true anymore.

dnish avatar Apr 27 '16 17:04 dnish

@timbrandin any update on this?

ralphievolt avatar May 24 '16 07:05 ralphievolt

@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.

timbrandin avatar May 24 '16 20:05 timbrandin

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));
      }
    });

Falieson avatar Jul 10 '16 20:07 Falieson

Any workarounds? I don't understand how to fix this(

focused avatar Jul 27 '16 17:07 focused

Any updates on this?

jasonnathan avatar Sep 05 '16 20:09 jasonnathan