-
Notifications
You must be signed in to change notification settings - Fork 763
fix(core): MediaObserver can report 1..n activations #994
Conversation
1b81cff
to
be51588
Compare
be51588
to
476521f
Compare
@CaerusKaru - ready for review. |
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.
Mostly good, just need to maintain old behavior in MediaObserver
src/apps/demo-app/src/app/media-query-status/media-query-status.component.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
/** HOF to sort the breakpoints by priority */ | ||
export function sortChangesByPriority(a: MediaChange, b: MediaChange): number { |
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.
Isn't this exported somewhere else?
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.
Different data types.
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.
Can we make the original a generic?
34df933
to
89ecba8
Compare
Previous versions of MediaObserver suffered from a significant design-flaw. Those versions assumed that a breakpoint change would only activate/match a single mediaQuery. Additionally those versions would not (by default) report overlapping activations. Applications interested in notifications for all current activations would therefore not receive proper event-notifications. The current enhancements provide several features: * Report 1..n mediaQuery activations (matches == true) in a single event * Report activations sorted by descending priority * By default, reports include overlapping breakpoint activations * Debounce notifications to a single grouped event > useful to reduce browser reflow thrashing Developers should note that while `media$: Observable< MediaChange >`, the `asObservable()` emits arrays: `Observable< MediaChange[] >`. BREAKING CHANGE: * `filterOverlaps` now defaults to `false`
89ecba8
to
341d13b
Compare
|
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. |
Previous versions of MediaObserver suffered from a significant design-flaw.
Those versions assumed that a breakpoint change would only activate/match a single mediaQuery. Additionally those versions would not (by default) report overlapping activations. Applications interested in notifications for all current activations would therefore not receive proper event-notifications.
The current enhancements provide several features:
BREAKING CHANGE:
The stream data type is now MediaChange[] instead of MediaChange and
media$
is deprecated in favor ofasObservable()
.filterOverlaps
now defaults tofalse
media$
is now aObservable< MediaChange[] >
instead ofObservable< MediaChange >