Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Last active December 8, 2021 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/0274fc3c045de1142d1276d377177565 to your computer and use it in GitHub Desktop.
Save NetanelBasal/0274fc3c045de1142d1276d377177565 to your computer and use it in GitHub Desktop.
import { fromEvent } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
function fromMediaQuery(breakpoint: string) {
const media = matchMedia(breakpoint);
return fromEvent(media, 'change').pipe(
map((e: MediaQueryListEvent) => e.matches),
startWith(media.matches)
)
}
@TousifMir
Copy link

I am trying to integrate this concept in my project, finding little difficulty as this article has just pieces. Getting this error, please help

Type 'Event' is missing the following properties from type 'MediaQueryListEvent': matches, media
map((e: MediaQueryListEvent) => e.matches),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment