@rxdi/ui-components
Version:
UI Components for building graphql-server website
54 lines (40 loc) • 1.16 kB
Markdown
# Responsive Service
#### Usage on Client side with /lit-html
```typescript
import { Module } from '@rxdi/core';
import { ResponsiveService } from '@rxdi/ui-components/services';
export class CoreModule {}
```
##### Using it inside component
> Remember to always unsubscribe from observables!
```typescript
import { html, LitElement, Component, css, property } from '@rxdi/lit-html';
import { Inject } from '@rxdi/core';
import { ResponsiveService } from '@rxdi/ui-components/services';
import { Subscription } from 'rxjs';
/**
* @customElement navbar-component
*/
export class NavbarComponent extends LitElement {
private responsive: ResponsiveService;
widthHeight: { width: number; height: number };
private subscription: Subscription = this.responsive
.combineBoth()
.subscribe(v => (this.widthHeight = v));
OnDestroy() {
if (this.subscription) {
this.subscription.unsubscribe();
}
}
}
```