Skip to content

Instantly share code, notes, and snippets.

View oleersoy's full-sized avatar

Ole Ersoy oleersoy

  • Firefly Semantics Corporation
  • Chicago
View GitHub Profile
import { Pipe, PipeTransform } from '@angular/core';
/**
* Strips any html characters
* from the `target`, abbreviates the resulting string
* to the max length, and appends an ellipsis character
* to the result.
*
* @example
* {{ title | ellipsis:200 }}
*/
let o1:Observable<boolean> = this.cb1.valueChanges;
let o2:Observable<boolean> = this.cb2.valueChanges;
merge(o1, o2).subscribe( v=>{
this.columnDefinitions[0].hide = this.cb1.value;
this.columnDefinitions[1].hide = this.cb2.value;
console.log(this.columnDefinitions);
});
}
export type Book = {
id: string;
volumeInfo: {
title: string;
subtitle: string;
authors: string[];
publisher: string;
publishDate: string;
description: string;
averageRating: number;
constructor(private http: HttpClient) {
this.bookStore.observeQuery().pipe(filter(Boolean),
debounceTime(200),
distinctUntilChanged(),
tap(async (query: string) => {
const bo: Observable<Book[]> = this.searchAPI(query);
const books: Book[] = await bo.toPromise();
this.bookStore.reset();
this.bookStore.postA(books);
})
import { NgModule } from '@angular/core';
import {
MatInputModule,
MatCardModule,
MatButtonModule,
MatSidenavModule,
MatListModule,
MatIconModule,
MatToolbarModule,
const isActiveTodoInCollection$:Observable<boolean> =
combineLatest(active$,
collection$,
(a, c)=>{
if (getMapValue(central.active)) {
return collection.containsById(getMapValue(central.active));
}
return false;
});
@oleersoy
oleersoy / pt.ts
Last active November 12, 2019 19:29
import { Component, Input } from '@angular/core';
import { Book } from '../model/';
@Component({
selector: 'bc-book-authors',
template: `
<h5 mat-subheader>Written By:</h5>
<span>
{{ authors | bcAddCommas }}
</span>
@oleersoy
oleersoy / rxjs.ts
Last active November 12, 2019 01:29
ngAfterViewInit() {
// server-side search
fromEvent(this.input.nativeElement,'keyup')
.pipe(
untilDestroyed(this),
filter(Boolean),
debounceTime(150),
distinctUntilChanged(),
tap(async (event:KeyboardEvent) => {
console.log(`The input value is ${this.input.nativeElement.value}`);
@oleersoy
oleersoy / debounce.ts
Last active November 7, 2019 22:29
dedbounce.ts
ngAfterViewInit() {
// server-side search
fromEvent(this.input.nativeElement,'keyup')
.pipe(
filter(Boolean),
debounceTime(150),
distinctUntilChanged(),
tap((text) => {
console.log(this.input.nativeElement.value)
import { Component, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'fs-toolbar',
template: `
<mat-toolbar color="primary">
<button mat-icon-button (click)="openMenu.emit()">
<mat-icon>menu</mat-icon>
</button>
<ng-content></ng-content>