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.

Property media$ was marked as deprecated without any alternatives

See original GitHub issue

I use the following code for defined if current media is desktop.

isDesktop$ = this._mediaObserver.media$.pipe(
    map((mediaChange: MediaChange) => [ 'xs', 'sm' ].indexOf(mediaChange.mqAlias) === -1)
);

But in version 7.0.0-beta.24 property media$ was deprecated. If I try to use method asObservable when I get array of media changes instead of one object. It doesn’t suit me because I need to match a few values with one media change.

I could not find some examples in documentation. What I should to do to avoid of using deprecated property?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Jemanuelscommented, Sep 25, 2019

This is how I have used it: Subscription.asObservable() .pipe( filter((changes: MediaChange[]) => changes.length > 0), map((changes: MediaChange[]) => changes[0]) ) .subscribe((change: MediaChange) => { if (change.mqAlias === ‘sm’ || change.mqAlias === ‘xs’) { // do something } else { // do something else } });

0reactions
angular-automatic-lock-bot[bot]commented, Jun 9, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deprecated HTML elements (and what to use instead)
The <dir> tag has been deprecated in favor of several alternatives that serve the same purpose with even more functionality. The <li> element ......
Read more >
Alternative for event's deprecated KeyboardEvent.which ...
When getting text input from the user, use the keypress event along with e.key; For shortcuts and other combinations, the built-in way is...
Read more >
Deprecated Fields, and Fields Marked as Obsolete
In the latest version of Business Central, a number of fields have been deprecated in the current release or marked to be obsolete...
Read more >
Deprecated APIs and features - Angular
This section lists all deprecated features, which includes template syntax, configuration options, and any other deprecations not listed in the Deprecated APIs ...
Read more >
Deprecation warnings in legacy JavaScript code using ...
deprecation is the discouragement of use of some terminology, feature, design, or practice […] without completely removing it or prohibiting ...
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