selectively tear down components

30 views
Skip to first unread message

Jorge Sanchez

unread,
Feb 5, 2015, 10:21:25 PM2/5/15
to twitter...@googlegroups.com
Hello everybody,

I have following situation. The component uiPost which handles showing the post on user timeline and also showing the post in popover when user goes over the notificaton feed. 
Before showing a new popover I basically tear down all the uiPosts for popovers. I didn't find any other way how to selectively tear down uiPost components only for popovers and not
for timeline so to do this I had to copy the uiPost to another file and rename it to uiPopoverPost. 

Is there any way how to change the signature of the component other then making a copy of it and renaming it ? 

Thanks,

Jorge

Tom Ashworth

unread,
Feb 6, 2015, 6:21:04 AM2/6/15
to Jorge Sanchez, twitter...@googlegroups.com
Hi Jorge,

We do something similar in TweetDeck, and it works like this: the popover uses the attachChild method from withChildComponents to host a component (in your case, uiPosts) — this links their lifecycles so that when the popover tears down, the uiPosts component will teardown. You can then fire an event to teardown the popover, which will cause the uiPosts to teardown. You shouldn't need to change uiPosts at all.

Caveat here: I don't know exactly what uiPosts does, or what the popover code looks like! This might not apply to you — but I'm happy to help further if you need it.

For more on the mixin, check out the link above and our blog post.
--
Tom
Reply all
Reply to author
Forward
0 new messages