Skip to content

Question about a page's state #135

Description

@wemped

Maybe this is more of a question about Redux in the context of flutter -- if you have an idea of a better place to ask this question let me know! Also happy to provide more detail if part of this doesn't make sense.

I understand that Redux can be very helpful when trying to handle changes and complex logic for the global app state, but how would you use it for complex state within a single page?

For example: You have a master/detail application. Master is a list of items, w/ very little info about each item. When you click on an item, it takes you to the detail page. The detail page contains info from a few different network endpoints -- maybe even some of these endpoints depending on results from each other.

I'd love to be able to use Actions/Reducers/View Models to handle the complex logic and dependencies between each network call, loading states, etc. But the underlying data isn't really global app state. In fact, I'd like that data to be disposed if I was to navigate back to the master page. So where should this detail logic live?

One idea would be to put it in the global store something like this

class AppState {
	final List<Item> items; //shown in the master view
	final ItemDetail itemDetail; //shown in the detail view
}

And nesting the reducers and so on

But then the data isn't disposed of automatically when the view is disposed.

Another problem is that, what if a detail could have a "link" to another item, so within a detail page we could open another detail page of a different item. This implementation would override the global app state's itemDetail.

So I guess my question is, how can I harness Redux's organization of logic within a single page in the context of a navigation stack like flutter's?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions