This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fakeAsync, tick } from '@angular/core/testing'; | |
import { of, throwError } from 'rxjs'; | |
import { mergeMap } from 'rxjs/operators'; | |
import { | |
exponentialBackoffRetry, | |
RETRY_COUNT, | |
RETRY_TIME, | |
} from './exponential-backoff-retry'; | |
describe('exponentialBackoffRetry', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable, pipe, range, throwError, zip, of, timer } from 'rxjs'; | |
import { map, mergeMap, retryWhen } from 'rxjs/operators'; | |
export const RETRY_COUNT = 3; | |
export const RETRY_TIME = 500; | |
export function exponentialBackoffRetry<T>( | |
maxTries: number = RETRY_COUNT, | |
delay: number = RETRY_TIME, | |
) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloServer, AuthenticationError } from 'apollo-server-express'; | |
import responseCachePlugin from 'apollo-server-plugin-response-cache'; | |
import * as express from 'express'; | |
import admin from 'firebase-admin'; | |
import { AuthIdentity, RequestContext } from './auth-identity'; | |
import { resolvers } from './resolvers'; | |
import { typeDefs } from './schema'; | |
/* Async verification with user token */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloServer, AuthenticationError } from 'apollo-server-express'; | |
import responseCachePlugin from 'apollo-server-plugin-response-cache'; | |
import * as express from 'express'; | |
import admin from 'firebase-admin'; | |
import { AuthIdentity, RequestContext } from './auth-identity'; | |
import { resolvers } from './resolvers'; | |
import { typeDefs } from './schema'; | |
/* Async verification with user token */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { region } from 'firebase-functions'; | |
import { gqlServer } from './app/server'; | |
import { environment } from './environments/environment'; | |
const dotenvJSON = require('dotenv-json'); | |
if (environment.production) { | |
dotenvJSON({ path: __dirname + '/assets/env.json' }); | |
} else { | |
dotenvJSON({ path: __dirname + '/assets/env.local.json' }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngOnDestroy(): void { | |
this.renderer.removeChild(this.elementRef.nativeElement, this.styleElement); | |
this.destroy$.next(); | |
this.destroy$.complete(); | |
} | |
ngOnInit() { | |
switchMap((courseId) => | |
this.courseFacade.getCourseCustomStyling(courseId) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getFlattenedParentRouteParams = (route: ActivatedRouteSnapshot) => { | |
if (!route.parent) { | |
return route.params; | |
} | |
const parentRouteParams = getFlattenedParentRouteParams(route.parent); | |
return { | |
...route.params, | |
...parentRouteParams, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
editCourseSubmitted(editedCourse: Course) { | |
return this.apollo.mutate<Course>({ | |
mutation: EDIT_COURSE_MUTATION, | |
variables: { | |
id: editedCourse.id, | |
name: editedCourse.name, | |
description: editedCourse.description, | |
} as Course, | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, ElementRef, HostListener, OnInit } from '@angular/core'; | |
import 'hammerjs'; | |
/* | |
Preventing clicks after a HammerJS press (long press) event. | |
Inspired from HammerJS ghost click helper: https://gist.github.com/jtangelder/361052976f044200ea17 | |
*/ | |
@Directive({ | |
selector: '[preventGhostClicks]', | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function removeFromCache<ReadQueryResponseT>( | |
toRemove: EntityObject, | |
readQuery: DocumentNode, | |
cache: ApolloCache<any>, | |
entityName: keyof ReadQueryResponseT | |
) { | |
const existingEntities = cache.readQuery< | |
Record<keyof ReadQueryResponseT, EntityObject[]> | |
>({ | |
query: readQuery, |
NewerOlder