-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More lifecycle hooks for top-level components. #11
Comments
@prook Thank you for opening up this discussion! I think that is a fantastic question. I think ultimately it comes down to a matter of taste, and so the following is just my personal preference: I agree with the recommendation by re-frame that using lifecycle hooks to load data is overloading the responsibility of the view layer. So if your preference is to start and stop websocket via lifecycle hooks, to proceed with with wrapping Anyways, just wanted to give my initial take on this topic, but I am happy to discuss it further. |
True, data retrieval seems inappropriate in the view layer. But what about something bound to the view more tightly? d3-force simulation, for instance. Lifecycle of I didn't mention d3-force initially to avoid digression, but now it seems unavoidable. Also, I thought finer lifecycle control could be good for other scenarios as well, but I fail to come up with examples (and if I do, they're easily dismantled) -- all lifecycle work not related to D3 (e. g., WebSockets) can be done outside But D3 stuff cries to be in So the question is, are there any other parts of D3 toolbox that could use finer lifecycle control? Or will this boil down to finding how to implement d3-force properly in #10 (and the digression was this whole issue)? 1 And also it gave me -- well, gives me -- quite a headache to figure out a how to plug in the simulation. I've found a few solutions which do work, even with GUP and nodes properly merging in the |
@prook Thanks for following up! I think you have convinced me that we should open up the api and add more lifecycle hooks to things like svg. So if you are willing to cook up some patches for that, I'd be happy to review it! Also, regarding force simulation specifically #10 , I haven't had time to look in to that. If you have a minimal, working example with rid3, it would be nice to see ... and then more to the point, we can brainstorm on what we can do to improve it! |
I've been playing around with on-the-fly D3 vizualizations: Changes to data are announced by server via a WebSocket notification. Upon receiving the notification, clients may download a fresh dataset, and update their vizualization.
The WebSocket needs to be opened at some point while initializing/mounting the viz component, and also needs to be closed when unmounting. I have been able to do this by wrapping
rid3/viz
into another component to manage the WS state, but it feels like a slight bodge.It seems more lifecycle hooks, say for the
:svg
element would make these need-cleanup scenarios easier. However, while pondering whether the whole WebSocket idea is not overly complicated, I started to wonder if the lack of said hooks was not intentional.So basically:
:svg
hash-map most likely), andThe text was updated successfully, but these errors were encountered: