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.

Explore using `selector-observer` to run features

See original GitHub issue

GitHub uses selector-observer to enable logic on simple classes, which is why adding or removing classes like .js-fit-content will enable or disable their features.

It’s built around MutationObserver with various optimizations on top of it. Its performance might not be super (https://bugzilla.mozilla.org/show_bug.cgi?id=1422522) but it seems to work well enough for GitHub.

It’s worth investigating if anyone has time, it would elegantly solve issues around dynamic content and all the specific listeners we have.

I think observe calls would go inside each feature’s init, which could only be called once.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
fregantecommented, Sep 25, 2020

@yakov116 if you also want to look into any other features that use selector-observer but don’t have this class, please send a PR for that

1reaction
fregantecommented, Sep 25, 2020

I confirmed the bug and found a workaround:

  • if the selector has :not(.rgh-this-feature) and we add the class right away, selector-observer will no longer call the add method because the original selector no longer applies. This avoids the loop.

We almost always do that already, but #3517 didn’t because it didn’t seem necessary.

  • I’ll open the previously-locked PRs
  • @kidonng you can resubmit #3517 with the workaround described #3531 already exists 👍
  • @yakov116 if you want to explore Monitoring anyway, try it out on linkify-code, which is the heaviest feature making use of selector-observer
Read more comments on GitHub >

github_iconTop Results From Across the Web

josh/selector-observer: Allows you to monitor DOM ... - GitHub
selector -observer allows you to monitor DOM elements that match a CSS selector. Rather than imperatively querying the DOM, register an observer for...
Read more >
Any way to use MutationObserver to watch for insertions of ...
One option is to use the Mutation Summary. Their API is pretty simple: var observer = new MutationSummary({ callback: function (changes) ...
Read more >
An Explanation of How the Intersection Observer Watches
This provides a way to identify which observer is in play in case a target is tied to multiple observers. The third section...
Read more >
A journey into NgRx Selectors - Angular inDepth
This article dives deep into NgRx selectors and will help you understand what role that play in NgRx architecture and how they help...
Read more >
Swift Selectors: Everything You Need to Know | Waldo Blog
So, in this article, we'll explore Objective-c selectors. You'll learn what they are and how to use them in Swift.
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