Skip to content

Instantly share code, notes, and snippets.

View cartant's full-sized avatar

Nicholas Jamieson cartant

View GitHub Profile
import { EMPTY, Observable, Subscription } from "rxjs";
import { concatMap, expand, map } from "rxjs/operators";
import { NotificationQueue } from "rxjs-etc";
import { get } from "./github";
function pages<T>(
uri: string,
notifier: Observable<any>
): Observable<T[]> {
return new Observable<any>(observer => {
import { EMPTY, Observable } from "rxjs";
import { expand, map, mergeMap, take } from "rxjs/operators";
import { get } from "./github";
function pages<T>(
uri: string,
notifier: Observable<any>
): Observable<T[]> {
return get<T[]>(uri).pipe(
expand(({ next }) => {
import { EMPTY, Observable, zip } from "rxjs";
import { expand, map } from "rxjs/operators";
import { get } from "./github";
function pages<T>(
uri: string,
notifier: Observable<any>
): Observable<T[]> {
return get<T[]>(uri).pipe(
expand(({ next }) => {
import { EMPTY, Observable } from "rxjs";
import { expand, map } from "rxjs/operators";
import { get } from "./github";
function pages<T>(uri: string): Observable<T[]> {
return get<T[]>(uri).pipe(
expand(({ next }) => next ? get(next) : EMPTY),
map(({ content }) => content)
);
}
import { ajax } from "rxjs/ajax";
import { map } from "rxjs/operators";
export function get<T>(uri: string): {
content: T,
next: string
} {
return ajax.get(uri).pipe(
map(({ response, xhr }) => ({
content: response,
import { pipe } from "rxjs";
import { ajax } from "rxjs/ajax"
import { concatMap, filter, ignoreElements } from "rxjs/operators";
/* ... */
collection.traverse(pipe(
filter(shouldPut),
concatMap(doc => ajax.put(
`${uri}/docs/${doc.id}`,
import { Observable, OperatorFunction } from "rxjs";
/* ... */
interface Collection {
traverse(): Observable<Document>;
traverse<R>(operator: OperatorFunction<Document, R>): Observable<R>;
}
import { Observable, OperatorFunction } from "rxjs";
/* ... */
interface Collection {
traverse(): Observable<Document>;
traverse<A>(
op1: OperatorFunction<Document, A>): Observable<A>;
traverse<A, B>(
op1: OperatorFunction<Document, A>,
import { pipe } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
const debounceInput = pipe(
debounceTime<string>(400),
distinctUntilChanged()
);
import { Observable } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
const debounceInput = (changes: Observable<string>) => changes.pipe(
debounceTime(400),
distinctUntilChanged()
);