Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Conversation

ThomasBurleson
Copy link
Contributor

@ThomasBurleson ThomasBurleson commented Jan 14, 2019

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

BREAKING CHANGE:

The stream data type is now MediaChange[] instead of MediaChange andmedia$ is deprecated in favor of asObservable().

  • filterOverlaps now defaults to false
  • media$ is now a Observable< MediaChange[] > instead of Observable< MediaChange >

@ThomasBurleson ThomasBurleson force-pushed the thomas/fix-media-observer branch 2 times, most recently from 1b81cff to be51588 Compare January 14, 2019 23:54
@ThomasBurleson ThomasBurleson added this to the 7.0.0-beta.24 milestone Jan 14, 2019
@ThomasBurleson ThomasBurleson force-pushed the thomas/fix-media-observer branch from be51588 to 476521f Compare January 14, 2019 23:58
@ThomasBurleson
Copy link
Contributor Author

@CaerusKaru - ready for review.

Copy link
Member

@CaerusKaru CaerusKaru left a 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

}

/** HOF to sort the breakpoints by priority */
export function sortChangesByPriority(a: MediaChange, b: MediaChange): number {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different data types.

Copy link
Member

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?

@CaerusKaru CaerusKaru self-assigned this Jan 15, 2019
@ThomasBurleson ThomasBurleson force-pushed the thomas/fix-media-observer branch 3 times, most recently from 34df933 to 89ecba8 Compare January 15, 2019 04:40
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`
@ThomasBurleson ThomasBurleson force-pushed the thomas/fix-media-observer branch from 89ecba8 to 341d13b Compare January 15, 2019 04:41
@ThomasBurleson
Copy link
Contributor Author

  • media$: Observable< MediaChange > behavior restored.
  • asObservable(): Observable< MediaChange[] >

@CaerusKaru CaerusKaru merged commit 8307655 into master Jan 15, 2019
@CaerusKaru CaerusKaru deleted the thomas/fix-media-observer branch January 15, 2019 05:17
@CaerusKaru CaerusKaru added pr: lgtm This PR has been approved by the reviewer pr: merge ready This PR is ready for the caretaker to presubmit and merge pr: merge safe The caretaker can merge this PR without doing a presubmit and removed pr: needs review labels Jan 15, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes pr: lgtm This PR has been approved by the reviewer pr: merge ready This PR is ready for the caretaker to presubmit and merge pr: merge safe The caretaker can merge this PR without doing a presubmit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants