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.

onAfterChanges option (or something similar)

See original GitHub issue

First of all thanks for this great library. I am using it for small reactive widgets in websites and it works like a charm.

In some scenarios i need to know, when morphing is completely finished. My approach now is to add onElUpdated, onNodeAdded and onNodeDiscarded and inside of the callbacks fire another callback which is throttled by request animation frame. This works for me, but is a little bit hacky in my opinion.

Would it be possible to provide an option - like onAfterChanges - which becomes invoked after everything has been done?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
leastbadcommented, May 31, 2022

I share your desire; it would be nice. In fact, I’m implementing a comparison concept in a library that uses morphdom right now.

Thing is, I would rather have morphdom be super fast than provide a changeset. I genuinely worry that making those changes available would require a lot more code and a lot more CPU cycles to run that code. (I’d be thrilled to be wrong.)

In our library, given that this functionality hasn’t been merged and released yet, we’re making use of the techniques discussed earlier in this thread - paired with an initial check where we compare the source fragment against the innerHTML of the target element. We figure that even if this is a heavy operation, it’s still less heavy than calling morphdom if we know the source and target are already equal.

If this functionality does get merged down the line, we’ll take that as an opportunity to simplify our local implementation by adopting the morphdom onAfterChanges event.

1reaction
leastbadcommented, May 27, 2022

Building on @StefanJelner’s solution - while acknowledging that I’m hoping for an outcome where a callback fires after processing even if there are no changes - is it fair and reasonable to say that a final call to onAfterChanges() immediately before line 753 would do the trick?

Read more comments on GitHub >

github_iconTop Results From Across the Web

kenwheeler/slick - I'm confused by the onAfterChange option
How do I pass the index to my function? currently, I'm doing this. var afterChangeFunc = function(index) { // do something; } mySlideshow.slick ......
Read more >
Slick slider on('afterChange')
I am trying to find option or method that gives me ability to change ... After change on the next slide, I would...
Read more >
HTMLElement: change event - Web APIs | MDN
The change event is fired for , , and elements when the user modifies the element's value. Unlike the input event, the change...
Read more >
JsViews custom tag controls: Declaring options
An alternative syntax is useful for declaring multiple tags: ... The onAfterChange() handler is called after tag has been updated by an observable...
Read more >
Tour API | Intro.js Docs
Parameters: options : Object - Object that contains option keys with values. Returns: introJs object. Example:.
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