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.

onremove() should return a promise for actually removing the element

See original GitHub issue

I wish the function onremove() were to return a promise to tell the library to actually remove the element, instead of our having to manually do so in our own implementation.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
okwolfcommented, Sep 9, 2017

@jbucaran how about supporting onremove returning a thunk? This seems like another case of an asynchronous update, except to the DOM instead of state. For example:

// If fadeout takes a callback function
<div onremove={element => remove => fadeout(element, remove)} />

// Or if fadeout returns a Promise
<div onremove={element => remove => fadeout(element).then(remove)} />

So instead of ignoring the return of data.onremove it would look something more like:

function removeElement(parent, element, data) {
  if (data && data.onremove) {
    var remover = data.onremove(element)
    if (typeof remover === "function") {
      remover(function() {
        parent.removeChild(element)
      });
    }
  } else {
    parent.removeChild(element)
  }
}
2reactions
Swizzcommented, Sep 16, 2017

We don’t want to support Promise in the core right ? So I approve the idea to make thunk a common practice for async operations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to wait for Promise to resolve before returning a new ...
Your current iteration through signIds 's Promises is not being chained with anything else - the .delete() Promises aren't being used ...
Read more >
Using promises - JavaScript - MDN Web Docs
Essentially, a promise is a returned object to which you attach callbacks, instead of passing callbacks into a function. Imagine a function, ...
Read more >
Lifecycle methods - Mithril.js
The onremove(vnode) hook is called before a DOM element is removed from the document. If a onbeforeremove hook is also defined, the onremove...
Read more >
Upgrading from AngularJS to Angular
If an element is owned by AngularJS, Angular treats it as if it didn't exist, ... You can still call $apply() so there...
Read more >
Updating For Beta 14 | Flarum Documentation
If a promise is returned, the DOM element will only be removed when the // promise completes. It is only called on the...
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