esentis / infinite_grouped_list

Dynamic scrolling list in Flutter, efficiently grouping items and seamlessly loading more data as user scrolls
https://pub.dev/packages/infinite_grouped_list
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

How do you use this with state management libraries such as bloc #3

Open becjit opened 6 months ago

becjit commented 6 months ago

Hi, first of all thanks for the package. I am a fan of your multiple search selection package. I am not quite able to wrap my head around how to use this with statemanagement solutions such as bloc. It seems to me call to fetch the data and loading the data both are tightly coupled in onLoadmore. Ideally onloadmore could have had a option of fireing an event and the data could have loaded through controller. Let me know if I am missing something obvious

esentis commented 6 months ago

Hello there @becjit thanks for your kind words ! So the bottom line, you would like a way of triggering the onLoadMore through the controller ? If I'm missing something please feel free to give an example of use case.

becjit commented 5 months ago

Hi, Let me try to break it down to you. What I followed from your example that onLoadMore both triggers and fetches the data. In your example when it is scrolled onLoadMore will get called with the offset and it will return the data.

Now imagine there is a state management solution like bloc where triggering the event and emitting the state is decoupled. In short using onLoadMore you can trigger an event to get more data which in turn trigger a state change.

Now my question is where do I listen for the state change?

Assuming you are familiar with flutter bloc that state change post onloadmore trigger could be listened through blocbuilder.

So in short the event trigger and widget renderings as a reaction to that event is decoupled

So in typical reactive programming where event trigger is decoupled from event listener I am not too sure we can make it work. It seemed to me onloadmore handles both event trigger and event listener part i. E. Trigger the fetch as well as return the result

Hope this clarifies. If needed I can quickly give you a pseudo code. Thanks. Abhijit

On Wed, 13 Mar 2024 at 3:23 PM, esentis @.***> wrote:

Hello there @becjit https://github.com/becjit thanks for your kind words ! So the bottom line, you would like a way of triggering the onLoadMore through the controller ? If I'm missing something please feel free to give an example of use case.

— Reply to this email directly, view it on GitHub https://github.com/esentis/infinite_grouped_list/issues/3#issuecomment-1993984614, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ4MLTU6SUXWMRNBG46DMTYYAOXZAVCNFSM6AAAAABETKIVLWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJTHE4DINRRGQ . You are receiving this because you were mentioned.Message ID: @.***>

esentis commented 5 months ago

@becjit Thank you for elaborating on this ! I think I know what you need, I will work on it when I find time and will get back at you.