Pagination icon indicating copy to clipboard operation
Pagination copied to clipboard

Publication is never ready inside constructor

Open kolyasya opened this issue 7 years ago • 11 comments

Hello, thank you for awesome and useful package.

I have troubles setting it up inside React component.

If I put publication definition outside of component everything works just fine:

image

But if I put it inside component constructor publication never loads. Sometimes it works (like 1 of 10 times) but usually not.

image

image

What am I doing wrong? Any ideas?

kolyasya avatar Oct 10 '18 17:10 kolyasya

I haven't been using it with react anymore, but most likely the issue is that Meteor does not register an active observer for the subscription. At the time of the implementation for meteor to get data inside react components react-meteor-data package was used which provided the getMeteorData() method to use for setting up subscriptions. Could you try wrapping the call to this.projectsPagination.getPage() in the withTracker() method from meteor?

Kurounin avatar Oct 12 '18 13:10 Kurounin

@Kurounin it is already inside withTracker method, which works the same as withTracker as I understand.

kolyasya avatar Oct 16 '18 14:10 kolyasya

Can you post part of the code where you call projectsPagination.getPage() ?

Kurounin avatar Oct 16 '18 15:10 Kurounin

@Kurounin does this screenshot works fine for you or you want me to post entire component?

image

kolyasya avatar Oct 16 '18 15:10 kolyasya

That's strange. I would have expected it to work as it is written. Can you create a sample project reproducing this issue?

Kurounin avatar Oct 17 '18 12:10 Kurounin

@Kurounin sure, later on this week

kolyasya avatar Oct 17 '18 13:10 kolyasya

Did you guys fix this? I have the same problem.

Trescend avatar Jan 09 '19 09:01 Trescend

@Trescend There was no follow-up. If you can create a sample project reproducing the issue I can take a look at it.

Kurounin avatar Jan 09 '19 20:01 Kurounin

Hi there. I still have this issue. I'm trying to init Meteor.Pagination with Meteor.Users collection in withTracker but in this case, the subscription will never be ready. Otherwise, if I'm initiating Meteor.Pagination at the root level of source file - any user methods (like Meteor.loginWithPassword or Meteor.logout) doesn't work (e.g Meteor.loginWithPassword was called, data about logged user was received and this was shown in the network tab but method callback wasn't invoked and won't be invoked). I found that this issue relates to the limit option for pagination subscription or default transform_options options and happens when opened more than one tab with my app (e.g two or more tabs with http://localhost:3000 in the Chrome, or one tab in the Chrome and one tab in Safari). When I removed limit and default options - methods were started to work again. There is transform_options with options. If I remove limit and ...options - methods will work

image

There is global pagination subscription for Users. I can't make this locally for the component - because subscription will never be ready (As Nikolay mentioned above)

image

Devlin556 avatar May 06 '20 10:05 Devlin556

Hi @Devlin556 I haven't been using meteor with react for a few years, so I would need a simple repo with the current standard setup that reproduces this issue, in order to be able to debug it.

Could you create a repository on github that reproduces this issue?

Kurounin avatar May 07 '20 10:05 Kurounin

@Kurounin Yesterday I noticed that it was cause by reactive field. I set it to false and methods was started working fine. I think i can’t reproduce this so easy.

Devlin556 avatar May 07 '20 11:05 Devlin556