-
Notifications
You must be signed in to change notification settings - Fork 771
fix(core): improve use of breakpoint priorities #946
Conversation
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
This includes the PR to remove deprecated APIs; to ensure optimizations work as desired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is stellar work; I'm especially amazed that more tests didn't need to be patched as a result. Just some minor cosmetic changes; functionally everything looks great!
d4c9619
to
6e66ab6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things missed the first time around. If there's a reason you're keeping them as-is, please provide.
@@ -99,7 +118,7 @@ export class MatchMedia { | |||
* Private global registry for all dynamically-created, injected style tags | |||
* @see prepare(query) | |||
*/ | |||
const ALL_STYLES: {[key: string]: any} = {}; | |||
const ALL_STYLES: { [key: string]: any } = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still no spaces (per style guide)
if (builder) { | ||
builder(); | ||
const clearFn: ClearCallback = builders.get(key) as ClearCallback; | ||
if (!!clearFn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, if(clearFn !== undefined)
if (builder) { | ||
builder(value); | ||
const updateFn: UpdateCallback = builders.get(key) as UpdateCallback; | ||
if (!!updateFn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, if (updateFn !== undefined)
private _registerBreakPoints() { | ||
const queries = this.breakpoints.sortedItems.map(bp => bp.mediaQuery); | ||
this.mediaWatcher.registerQuery(queries); | ||
private watchActivations() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, add return type
let nonOverlaps = this._registry.filter(it => it.overlapping !== true); | ||
|
||
return [...overlaps, ...nonOverlaps]; | ||
constructor(@Inject(BREAKPOINTS) list: BreakPoint[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a thought: the items
remain static, so instead of memoizing, why not just prime it at startup by creating two maps on init, one for aliases, one for mediaqueries?
Use breakpoint priority as the only sorting/scanning mechanism; used to ensure correct MediaChange event notifications. * prioritize breakpoints: non-overlaps hightest, lt- lowest * consistently sort breakpoints ascending by priority * highest priority === smallest range * remove hackery with reverse(), etc. * memoize BreakPointRegistry findBy lookups * fix MatchMedia::observe() to support lazy breakpoint registration * fix fragile logic in MediaMarshaller * fix breakpoint registration usage * clarify update/clear builder function callbacks * fix MediaObserver breakpoint registration usage Fixes #648, Fixes #426
6e66ab6
to
350e753
Compare
CLAs look good, thanks! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Use breakpoint priority as the only sorting/scanning mechanism;
used to ensure correct MediaChange event notifications.