Skip to content

Instantly share code, notes, and snippets.

@vmasek
Created July 24, 2019 18:30
Show Gist options
  • Save vmasek/1735a45f21e257596fd5eff12bcce2c3 to your computer and use it in GitHub Desktop.
Save vmasek/1735a45f21e257596fd5eff12bcce2c3 to your computer and use it in GitHub Desktop.
let directive multiple values example
@Component({
selector: 'app-root',
template: `
<h1>mouse</h1>
<p
*viLet="{
click: mouseClick$ | async,
move: mouseMove$ | async,
interval: interval$ | async,
} as mouse"
>
click [{{ mouse.click?.screenX }}, {{ mouse.click?.screenY }}]
<br />
move [{{ mouse.move?.screenX }}, {{ mouse.move?.screenY }}]
<br />
seconds from start {{ mouse.interval }}
<br />
</p>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
readonly mouseClick$ = fromEvent(document, 'click') as Observable<MouseEvent>;
readonly mouseMove$: Observable<Event> = fromEvent(document, 'mousemove');
readonly interval$ = interval(1000).pipe(startWith(0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment