Skip to content

Instantly share code, notes, and snippets.

Avatar

Ole Ersoy oleersoy

  • Firefly Semantics Corporation
  • Chicago
View GitHub Profile
View model.ts
export type Book = {
id: string;
volumeInfo: {
title: string;
subtitle: string;
authors: string[];
publisher: string;
publishDate: string;
description: string;
averageRating: number;
View search.ts
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);
})
View material-slice.ts
import { NgModule } from '@angular/core';
import {
MatInputModule,
MatCardModule,
MatButtonModule,
MatSidenavModule,
MatListModule,
MatIconModule,
MatToolbarModule,
View ts.ts
const isActiveTodoInCollection$:Observable<boolean> =
combineLatest(active$,
collection$,
(a, c)=>{
if (getMapValue(central.active)) {
return collection.containsById(getMapValue(central.active));
}
return false;
});
View pt.ts
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>
View rxjs.ts
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}`);
View toolbar.ts
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>
View gist:a70c1e455cde8a986bc79b6e3477cd49
const googleLogoURL =
"https://raw.githubusercontent.com/fireflysemantics/logo/master/Google.svg";
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
constructor (
View console.ts
export class Console {
textarea: HTMLTextAreaElement;
constructor(container: HTMLElement) {
this.textarea = document.createElement("textarea");
container.appendChild(this.textarea);
}
/**
* @param
*/
log(message: string, type?: string) {
View input.ts
const postCategories: PostCategory[] = [
{
id: "iot",
name: "IOT",
summary: "Internet of Things Posts.",
posts: [
{
id: "thermostat",
title: "Thermostat",
content: "How to make it really cold fast!"