Open Bug 1553950 Opened 7 months ago Updated 7 months ago

We have way too many variants of promiseObserved


(Toolkit :: General, task, P5)




Tracking Status
firefox69 --- affected


(Reporter: kmag, Unassigned, NeedInfo)




Currently we have, for a start, 3 general-purpose helper functions to return a promise when an observer has been notified:

This is not the end of the world, but it would be nice if these could all be replaced with a single helper in toolkit.

However, according to this horrendous one-liner and some code reading:

hg manifest | grep '\.jsm?$' | perl -e 'for my $fn (<STDIN>) { chomp($fn); eval { open(my $fh, "<", $fn); my $meh = join("", <$fh>); if ($meh =~ /new Promise\(.*\n.*(Services.obs.addObserver|ubject.*opic)/) { print $fn, "\n"; } } }'

we actually have many, many more, with varying degrees of badness. Some don't even remove the observer. Some are multiple repetitions of the same code for different topics. Most of them make the code around them difficult to follow.

We should try to update most of these to use the shared helper, and possibly even add an ESLint rule to prevent people from adding new instances.

Apparently Johann promised to file a follow-up to fix some of this in bug 1529643.

Type: defect → task
Regressed by: 1529643
Flags: needinfo?(jhofmann)
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.