简体   繁体   中英

Flux - Stores' data lifecycle

There's one thing about Flux (or at least about its implementations) that I don't quite understand. It's about internal data management of Stores. I'll try to explain my question by breaking it down into points. Let's imagine I have some app with client-side routing.

  1. As I understood Stores are singletons. Somewhere they store some data (eg an array)

  2. User clicks somewhere and navigates to some part of the app. Correspoding Store fetches some data. Let's imagine that it's a really big amount of data. So big that it takes a lot of resources and even makes page laggy.

  3. After a while user navigates to a different route. What happens with the internal data of the Store mentioned above? As far as I understood, it remains intact. At least until user navigates to original route and the Store changes its state. And before that happens the Store holds big amount of data even when it's not needed.

Can someone clear this out for me? Thanks.

Store just listen the dispatcher(actions) and somehow react on it. In example you mention - yes, it will hold the data at least you don't use weakmap or kinda, but you also can listen actions on changing routes and process your data in this case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM