selectCurrentBreakpoint$(): Observable<Breakpoint>¶
The selectCurrentBreakpoint$
method allows you to get an observable with a currently active breakpoint.
Returned value¶
A returned value has a type of Observable<Breakpoint>
where Breakpoint
represents the Breakpoint model.
Example¶
In this example we make a ResolutionDetectorApi
call to get an observable with a currently active breakpoint.
useStorefront(async (storefront) => {
const resolutionDetectorApi = storefront.getApiSync('ResolutionDetectorApi');
const currentBreakpoint$ = resolutionDetectorApi.selectCurrentBreakpoint$();
currentBreakpoint$.subscribe((breakpoint) => {
console.log(`Current breakpoint is ${breakpoint.name} which applies to screens of ${breakpoint.value}px width and below.`);
});
});