Proper DOM cleanup while driver disposal
See original GitHub issueThis problem is actual for such use cases as hot-reload of cycle app, or then cycle apps are pereodically instantiated while runtime.
In such scenarios when don’t need running app anymore we dispose all sinks and sources, then probably cleanup HTML and replace with with new instance.
The problem is that while DOM driver disposal vdom tree is not cleaned up and thus destroy
hooks on elements (widgets) do not work, this may cause some leaks and side effects.
To address this issue I curretly use use this as a solution:
const _makeDOMDriver = (contaner, options) =>
(dom$) => {
let empty$ = new BehaviorSubject()
empty$.onNext(false)
let source = makeDOMDriver(contaner, options)(
Observable.combineLatest(dom$, empty$, (dom, empty) => {
return empty ? div('') /* empty dom */ : dom}
)
)
let _dispose = source.dispose
source.dispose = () => {
empty$.onNext(true)
_dispose.apply(source)
}
return source
}
I wonder if something like this (vdom cleanup) should be done by DOM driver by default while disposal.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Tips to Keep Drivers and Waste Processing Employees Safe
SEAL AND MARK ALL SHARPS/NEEDLES – Properly dispose of medical sharp objects such as syringes by placing them in a sealed, rigid plastic ......
Read more >react hooks useEffect() cleanup for only ... - Stack Overflow
If I want to make this component to log 'cleaned up' for only the moment when it is unmount, I just have to...
Read more >Clean Up and Disposal - New York State Department of Health
NEVER use a vacuum cleaner, mop or broom to clean it up. Don't walking through the spilled area. Take children and pets to...
Read more >Cleanup of Ian's mess is ongoing, but be sure you know the ...
Please be advised that debris removal crews WILL NOT, enter onto private property to collect or remove debris. Normal Household Trash - normal ......
Read more >Guidelines for Cleanup Day Coordinators - Monterey County
Ensure that all waste collected from the cleanup site is properly removed and disposed of. When organizing the cleanup contact the local scrap...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Frikki https://github.com/cyclejs/dom/pull/128 you may look in to this, it was almost implemented, but not finished.
@whitecolor
No, they don’t. I have been attempting to implement the suggestions with the latest releases, but to little avail. Hence, my request.UPDATE: I am so sorry. Forget it. The library wasn’t compiling automatically when I ran the browser tests.