question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proper DOM cleanup while driver disposal

See original GitHub issue

This 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:closed
  • Created 8 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
wclrcommented, Sep 26, 2016

@Frikki https://github.com/cyclejs/dom/pull/128 you may look in to this, it was almost implemented, but not finished.

0reactions
Frikkicommented, Sep 27, 2016

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found