Factory/family capsule rebuild #48
Replies: 2 comments 1 reply
-
Okay, I remebered the reduce rebuild doc section. I'm gonna take a look again over that. Seems to the solution. Anyway, would be ok for you to rebuild the whole capsule in this scenario? |
Beta Was this translation helpful? Give feedback.
0 replies
-
short answer: it depends.
How many downstream capsules are using the factory? If the answer is none (I.e., you’re doing container.read of the factory from a webserver), then you can probably do manual listeners in the controller. If you do have some downstream capsules, you may want to rely on ReArch’s propagation (and can .map() the capsules into something else to avoid some widget rebuilds).
idk if it’s possible here, but your controllers should likely be entirely immutable. Capsule data tends to bode better when immutable.
An fyi: as a best practice your code can be simplified with a hashmap.putIfAbsent instead of a null check in the factory.
also, I’ll review your other discussion post when I get a chance I’ve been really busy the past few days
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
GregoryConrad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's say I have a
Set<String>
for every websocket connection (In my real world app it correspond to passwords id's). This is a base code:So the issue that I'm thinking of would be when I receive an event for an added/removed id for a unique websocket connection.
I can think of two options to notify a change to my Table widget:
passwordIdsControllerFamily
capsule. This way I will rebuild also widgets that only use other websocket connection ids._Controller
. That way is more selective but I add extra logic outside the ReArch mechanisms.What do you think about this?
Beta Was this translation helpful? Give feedback.
All reactions