Kurounin / Pagination

This package allows you to paginate the subscriptions over meteor's collections. It can be used in a Blaze template or in ReactJS.
MIT License
56 stars 22 forks source link

Publication is never ready inside constructor #89

Closed kolyasya closed 1 year ago

kolyasya commented 6 years ago

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?

Kurounin commented 6 years ago

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?

kolyasya commented 6 years ago

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

Kurounin commented 6 years ago

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

kolyasya commented 6 years ago

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

image

Kurounin commented 6 years ago

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

kolyasya commented 6 years ago

@Kurounin sure, later on this week

Trescend commented 5 years ago

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

Kurounin commented 5 years ago

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

Devlin556 commented 4 years ago

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

Kurounin commented 4 years ago

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?

Devlin556 commented 4 years ago

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